Skip to content

Azure Cache for Redis documentation and test-case improvement #15927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
73f1dbd
Improving test case for zone redundancy
AnshulBhl Aug 26, 2021
8de1a51
Updated the usage option and addedthe examples for Zones Redundancy a…
AnshulBhl Aug 30, 2021
3b244a9
Added PS module and usage doc for PE
AnshulBhl Sep 7, 2021
5abd57e
Added example for Data Persistence
AnshulBhl Sep 7, 2021
3052920
Edits for Draft PR
AnshulBhl Sep 10, 2021
28bb427
Added json file for test case change
AnshulBhl Sep 10, 2021
707fca4
Adding functional test for Private Endpoint
AnshulBhl Sep 13, 2021
90ac27f
Checking markdown file online
AnshulBhl Sep 14, 2021
4929fe5
Checking Markdown
AnshulBhl Sep 14, 2021
89c9880
Checking Format of Markdown file
AnshulBhl Sep 14, 2021
a8b3b35
Added revised files
AnshulBhl Sep 14, 2021
cfd46ee
Deleted File
AnshulBhl Sep 15, 2021
b1d160f
Changes corresponding to draft PR
AnshulBhl Sep 15, 2021
4561ee2
Edited markdown files as suggested
AnshulBhl Sep 20, 2021
5be1502
Missed changes from document review
AnshulBhl Sep 22, 2021
03fb4cc
Changed link to hyperlink
AnshulBhl Sep 22, 2021
745a607
Changes the code break
AnshulBhl Sep 27, 2021
d8b2bc7
Edited Changelog and remove the errors
AnshulBhl Sep 28, 2021
122cf0a
Removing Private endpoints command
AnshulBhl Sep 29, 2021
08cc57d
Changed the unwanted changes
AnshulBhl Sep 30, 2021
10d4c36
trying to remove timeout
AnshulBhl Oct 4, 2021
16275d7
Correct Resource.designer.cs
AnshulBhl Oct 4, 2021
d752158
Update ChangeLog.md
dingmeng-xue Oct 4, 2021
f629368
Change the description of help message
AnshulBhl Oct 6, 2021
6768247
Merge branch 'anshul/cacheFeatures' of https://github.com/AnshulBhl/a…
AnshulBhl Oct 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/RedisCache/RedisCache.Test/RedisCache.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PsModuleName>RedisCache</PsModuleName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ function Test-Zones
New-AzResourceGroup -Name $resourceGroupName -Location $location

# Creating Cache
$cacheCreated = New-AzRedisCache -ResourceGroupName $resourceGroupName -Name $cacheName -Location $location -Size P1 -Sku Premium -Zone @("1") -Tag @{"example-key" = "example-value"}
$cacheCreated = New-AzRedisCache -ResourceGroupName $resourceGroupName -Name $cacheName -Location $location -Size P1 -Sku Premium -Zone @("1","2") -Tag @{"example-key" = "example-value"}

Assert-AreEqual $cacheName $cacheCreated.Name
Assert-AreEqual $location $cacheCreated.Location
Expand All @@ -838,6 +838,7 @@ function Test-Zones
Assert-AreEqual "6GB" $cacheCreated.Size
Assert-AreEqual "Premium" $cacheCreated.Sku
Assert-AreEqual "1" $cacheCreated.Zone[0]
Assert-AreEqual "2" $cacheCreated.Zone[1]
Assert-AreEqual "example-value" $cacheCreated.Tag.Item("example-key")
Assert-NotNull $cacheCreated.PrimaryKey "PrimaryKey do not exists"
Assert-NotNull $cacheCreated.SecondaryKey "SecondaryKey do not exists"
Expand All @@ -851,6 +852,7 @@ function Test-Zones
{
Assert-AreEqual $cacheName $cacheGet[0].Name
Assert-AreEqual "1" $cacheGet[0].Zone[0]
Assert-AreEqual "2" $cacheGet[0].Zone[1]
Assert-AreEqual "example-value" $cacheGet[0].Tag.Item("example-key")
break
}
Expand All @@ -864,7 +866,6 @@ function Test-Zones
Remove-AzResourceGroup -Name $resourceGroupName -Force
}


<#
.SYNOPSIS
Sleeps but only during recording.
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/RedisCache/RedisCache/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Created new examples in documentation of `New-AzRedisCache` and `Set-AzRedisCache`.

## Version 1.5.0
* Added `RedisVersion` parameter in `New-AzRedisCache` and `Set-AzRedisCache`
Expand Down
4 changes: 2 additions & 2 deletions src/RedisCache/RedisCache/Commands/NewAzureRedisCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class NewAzureRedisCache : RedisCacheCmdletBase
[PSArgumentCompleter(TlsStrings.OneFullStopZero, TlsStrings.OneFullStopOne, TlsStrings.OneFullStopTwo)]
public string MinimumTlsVersion { get; set; }

[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "The full resource ID of a subnet in a virtual network to deploy the redis cache in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1")]
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "The full resource ID of a subnet in a virtual network to deploy the Azure Cache for Redis in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/{vnetName}/subnets/{subnetName}")]
public string SubnetId { get; set; }

[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "Required when deploying a redis cache inside an existing Azure Virtual Network.")]
Expand All @@ -77,7 +77,7 @@ public class NewAzureRedisCache : RedisCacheCmdletBase
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "A hash table which represents tags.")]
public Hashtable Tag { get; set; }

[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "List of zones.")]
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "List of Azure regions with Availability zones.")]
public string[] Zone { get; set; }

[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "Redis version. Valid values: 4, 6")]
Expand Down
2 changes: 1 addition & 1 deletion src/RedisCache/RedisCache/Commands/SetAzureRedisCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class SetAzureRedisCache : RedisCacheCmdletBase
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }

[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Name of redis cache.")]
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Specifies the name of the Azure Cache for Redis to update.")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

Expand Down
142 changes: 140 additions & 2 deletions src/RedisCache/RedisCache/help/New-AzRedisCache.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,142 @@ PS C:\>New-AzRedisCache -ResourceGroupName "MyGroup" -Name "MyCache" -Location "
Zone : []
```

This command creates a Redis Cache.
This cmdlet creates a cache using Azure Cache for Redis.

### Example 3: Create a Zone Redundant Cache

```
PS C:\> New-AzRedisCache -ResourceGroupName "MyGroup" -Name "MyCache" -Location "Central US" -Size P1 -Sku "Premium" -Zone @("1","2")

PrimaryKey : pJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
SecondaryKey : sJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
ResourceGroupName : MyGroup
Id : /subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/mygroup/providers/Microsoft.Cache/Redis/MyCache
Location : Central US
Name : mycache
Type : Microsoft.Cache/Redis
HostName : mycache.redis.cache.windows.net
Port : 6379
ProvisioningState : creating
SslPort : 6380
RedisConfiguration : {[maxmemory-policy, allkeys-random], [maxclients, 7500], [maxmemory-reserved, 200],
[maxfragmentationmemory-reserved, 300]...}
EnableNonSslPort : False
RedisVersion : 4.0.14
Size : 6GB
Sku : Premium
Tag : {}
Zone : {1, 2}
```
This command creates Azure cache for Redis instance in mutliple zones.

### Example 4: Create a Virtual Network enable Cache

Requirements for creating Virtual Network enable cache.
1. Create the virtual network in same resource group in which you want to create your redis cache. You can create virtual network from [New-AzVirtualNetwork](./../../../Network/Network/help/New-AzVirtualNetwork.md) powershell command.
1. You will need SubnetID for VNET enable cache. Syntax of SubnetID is given below.

Format of SubnetID: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/providers/Microsoft.ClassicNetwork/VirtualNetworks/{vnetName}/subnets/{subnetName}

```
PS C:\> New-AzRedisCache -ResourceGroupName "MyGroup" -Name "MyCache" -Location "Central US" -Size P1 -Sku "Premium" -SubnetId "/subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/mygroup/providers/Microsoft.Network/virtualNetworks/MyNet/subnets/MySubnet"

PrimaryKey : pJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
SecondaryKey : sJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
ResourceGroupName : MyGroup
Id : /subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/mygroup/providers/Microsoft.Cache/Redis/MyCache
Location : Central US
Name : mycache
Type : Microsoft.Cache/Redis
HostName : mycache.redis.cache.windows.net
Port : 6379
ProvisioningState : creating
SslPort : 6380
RedisConfiguration : {[maxmemory-policy, allkeys-random], [maxclients, 7500], [maxmemory-reserved, 200],
[maxfragmentationmemory-reserved, 300]...}
EnableNonSslPort : False
RedisVersion : 4.0.14
Size : 6GB
Sku : Premium
SubnetId : /subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/mygroup/providers/Microsoft.Network/virtualNetworks/MyNet/subnets/MySubnet
StaticIP : 10.0.0.4
Tag : {}
Zone : []
```

### Example 5: Configure data persistence for a Premium Azure Cache for Redis

Persistence writes Redis data into an Azure Storage account that you own and manage. So before configuring data persistence you need to have [storage account](https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-powershell) in same resource group. Choose a storage account in the same region and subscription as the cache, and a Premium Storage account is recommended because premium storage has higher throughput.

After creating a storage account, get the storage account connection string using this procedure.

1. Run this command **Get-AzStorageAccountKey -ResourceGroupName $resourceGroupName -Name $storageAccountName** in powershell.
1. From the output of above, copy any key.
1. Put the storage account key and the storage account name in format below to get the connection string of your storage account.

Connection String Format :- "DefaultEndpointsProtocol=https;AccountName={storageAccountName};AccountKey={storageAccountKey};EndpointSuffix=core.windows.net"</br>

You must have the specific Redis configuration settings to enable data persistence.

For RDB backup enable
- rdb-backup-enabled (Set true or false)
- rdb-storage-connection-string (Give connection string in above format.)
- rdb-backup-frequency (Set a backup interval in minutes. You can only choose from - 15, 30, 60, 360, 720 and 1440 minutes.)

```
PS C:\> New-AzRedisCache -ResourceGroupName "MyGroup" -Name "MyCache" -Location "Central US" -Size P1 -Sku "Premium" -RedisConfiguration @{"rdb-backup-enabled" = "true"; "rdb-storage-connection-string" = "DefaultEndpointsProtocol=https;AccountName=mystorageaccount;AccountKey=pJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=;EndpointSuffix=core.windows.net"; "rdb-backup-frequency" = "30"}

PrimaryKey : pJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
SecondaryKey : sJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
ResourceGroupName : MyGroup
Id : /subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/mygroup/providers/Microsoft.Cache/Redis/MyCache
Location : Central US
Name : mycache
Type : Microsoft.Cache/Redis
HostName : mycache.redis.cache.windows.net
Port : 6379
ProvisioningState : creating
SslPort : 6380
RedisConfiguration : {[maxmemory-policy, allkeys-random], [maxclients, 7500], [maxmemory-reserved, 200],
[maxfragmentationmemory-reserved, 300], [rdb-backup-enabled, true]....}
EnableNonSslPort : False
RedisVersion : 4.0.14
Size : 6GB
Sku : Premium
Tag : {}
Zone : []
```

### Example 6: Configure data persistence for a Premium Azure Cache for Redis - AOF backup enabled

For AOF back up enabled.
- aof-backup-enabled (Set true or false),
- aof-storage-connection-string-0 (Give connection string in above format.)
- aof-storage-connection-string-1 (You can optionally configure another storage account. If a second storage account is configured, the writes to the replica cache are written to this second storage account.)

```
PS C:\> New-AzRedisCache -ResourceGroupName "MyGroup" -Name "MyCache" -Location "Central US" -Size P1 -Sku "Premium" -RedisConfiguration @{"aof-backup-enabled" = "true"; "aof-storage-connection-string-0" = "DefaultEndpointsProtocol=https;AccountName=mystorageaccount;AccountKey=pJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=;EndpointSuffix=core.windows.net"}

PrimaryKey : pJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
SecondaryKey : sJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
ResourceGroupName : MyGroup
Id : /subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/mygroup/providers/Microsoft.Cache/Redis/MyCache
Location : Central US
Name : mycache
Type : Microsoft.Cache/Redis
HostName : mycache.redis.cache.windows.net
Port : 6379
ProvisioningState : creating
SslPort : 6380
RedisConfiguration : {[maxmemory-policy, allkeys-random], [maxclients, 7500], [maxmemory-reserved, 200],
[maxfragmentationmemory-reserved, 300], [aof-backup-enabled, true]...}
EnableNonSslPort : False
RedisVersion : 4.0.14
Size : 6GB
Sku : Premium
Tag : {}
Zone : []
```

## PARAMETERS

Expand Down Expand Up @@ -356,6 +491,9 @@ Accept wildcard characters: False
```

### -SubnetId
The full resource ID of a subnet in a virtual network to deploy the Azure Cache for Redis in.
Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/{vnetName}/subnets/{subnetName}

```yaml
Type: System.String
Parameter Sets: (All)
Expand Down Expand Up @@ -399,7 +537,7 @@ Accept wildcard characters: False
```

### -Zone
List of zones.
List of Azure regions with [Availability zones](https://docs.microsoft.com/en-us/azure/availability-zones/az-region#azure-services-supporting-availability-zones).

```yaml
Type: System.String[]
Expand Down
Loading