Skip to content

Commit db94918

Browse files
Azure Cache for Redis documentation and test-case improvement (#15927)
* Improving test case for zone redundancy * Updated the usage option and addedthe examples for Zones Redundancy and Virtual Network * Added PS module and usage doc for PE * Added example for Data Persistence * Edits for Draft PR * Added json file for test case change * Adding functional test for Private Endpoint * Checking markdown file online * Checking Markdown * Checking Format of Markdown file * Added revised files * Deleted File * Changes corresponding to draft PR * Edited markdown files as suggested * Missed changes from document review * Changed link to hyperlink * Changes the code break * Edited Changelog and remove the errors * Removing Private endpoints command * Changed the unwanted changes * trying to remove timeout * Correct Resource.designer.cs * Update ChangeLog.md * Change the description of help message Co-authored-by: Dingmeng Xue <[email protected]>
1 parent 0d984c0 commit db94918

File tree

8 files changed

+990
-1156
lines changed

8 files changed

+990
-1156
lines changed

src/RedisCache/RedisCache.Test/RedisCache.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<PsModuleName>RedisCache</PsModuleName>

src/RedisCache/RedisCache.Test/ScenarioTests/RedisCacheTests.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ function Test-Zones
829829
New-AzResourceGroup -Name $resourceGroupName -Location $location
830830

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

834834
Assert-AreEqual $cacheName $cacheCreated.Name
835835
Assert-AreEqual $location $cacheCreated.Location
@@ -838,6 +838,7 @@ function Test-Zones
838838
Assert-AreEqual "6GB" $cacheCreated.Size
839839
Assert-AreEqual "Premium" $cacheCreated.Sku
840840
Assert-AreEqual "1" $cacheCreated.Zone[0]
841+
Assert-AreEqual "2" $cacheCreated.Zone[1]
841842
Assert-AreEqual "example-value" $cacheCreated.Tag.Item("example-key")
842843
Assert-NotNull $cacheCreated.PrimaryKey "PrimaryKey do not exists"
843844
Assert-NotNull $cacheCreated.SecondaryKey "SecondaryKey do not exists"
@@ -851,6 +852,7 @@ function Test-Zones
851852
{
852853
Assert-AreEqual $cacheName $cacheGet[0].Name
853854
Assert-AreEqual "1" $cacheGet[0].Zone[0]
855+
Assert-AreEqual "2" $cacheGet[0].Zone[1]
854856
Assert-AreEqual "example-value" $cacheGet[0].Tag.Item("example-key")
855857
break
856858
}
@@ -864,7 +866,6 @@ function Test-Zones
864866
Remove-AzResourceGroup -Name $resourceGroupName -Force
865867
}
866868

867-
868869
<#
869870
.SYNOPSIS
870871
Sleeps but only during recording.

src/RedisCache/RedisCache.Test/SessionRecords/Microsoft.Azure.Commands.RedisCache.Test.ScenarioTests.RedisCacheTests/TestZones.json

Lines changed: 615 additions & 1143 deletions
Large diffs are not rendered by default.

src/RedisCache/RedisCache/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Created new examples in documentation of `New-AzRedisCache` and `Set-AzRedisCache`.
2122

2223
## Version 1.5.0
2324
* Added `RedisVersion` parameter in `New-AzRedisCache` and `Set-AzRedisCache`

src/RedisCache/RedisCache/Commands/NewAzureRedisCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class NewAzureRedisCache : RedisCacheCmdletBase
6868
[PSArgumentCompleter(TlsStrings.OneFullStopZero, TlsStrings.OneFullStopOne, TlsStrings.OneFullStopTwo)]
6969
public string MinimumTlsVersion { get; set; }
7070

71-
[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")]
71+
[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}")]
7272
public string SubnetId { get; set; }
7373

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

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

8383
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "Redis version. Valid values: 4, 6")]

src/RedisCache/RedisCache/Commands/SetAzureRedisCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class SetAzureRedisCache : RedisCacheCmdletBase
3232
[ValidateNotNullOrEmpty]
3333
public string ResourceGroupName { get; set; }
3434

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

src/RedisCache/RedisCache/help/New-AzRedisCache.md

Lines changed: 140 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,142 @@ PS C:\>New-AzRedisCache -ResourceGroupName "MyGroup" -Name "MyCache" -Location "
7676
Zone : []
7777
```
7878

79-
This command creates a Redis Cache.
79+
This cmdlet creates a cache using Azure Cache for Redis.
80+
81+
### Example 3: Create a Zone Redundant Cache
82+
83+
```
84+
PS C:\> New-AzRedisCache -ResourceGroupName "MyGroup" -Name "MyCache" -Location "Central US" -Size P1 -Sku "Premium" -Zone @("1","2")
85+
86+
PrimaryKey : pJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
87+
SecondaryKey : sJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
88+
ResourceGroupName : MyGroup
89+
Id : /subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/mygroup/providers/Microsoft.Cache/Redis/MyCache
90+
Location : Central US
91+
Name : mycache
92+
Type : Microsoft.Cache/Redis
93+
HostName : mycache.redis.cache.windows.net
94+
Port : 6379
95+
ProvisioningState : creating
96+
SslPort : 6380
97+
RedisConfiguration : {[maxmemory-policy, allkeys-random], [maxclients, 7500], [maxmemory-reserved, 200],
98+
[maxfragmentationmemory-reserved, 300]...}
99+
EnableNonSslPort : False
100+
RedisVersion : 4.0.14
101+
Size : 6GB
102+
Sku : Premium
103+
Tag : {}
104+
Zone : {1, 2}
105+
```
106+
This command creates Azure cache for Redis instance in mutliple zones.
107+
108+
### Example 4: Create a Virtual Network enable Cache
109+
110+
Requirements for creating Virtual Network enable cache.
111+
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.
112+
1. You will need SubnetID for VNET enable cache. Syntax of SubnetID is given below.
113+
114+
Format of SubnetID: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/providers/Microsoft.ClassicNetwork/VirtualNetworks/{vnetName}/subnets/{subnetName}
115+
116+
```
117+
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"
118+
119+
PrimaryKey : pJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
120+
SecondaryKey : sJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
121+
ResourceGroupName : MyGroup
122+
Id : /subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/mygroup/providers/Microsoft.Cache/Redis/MyCache
123+
Location : Central US
124+
Name : mycache
125+
Type : Microsoft.Cache/Redis
126+
HostName : mycache.redis.cache.windows.net
127+
Port : 6379
128+
ProvisioningState : creating
129+
SslPort : 6380
130+
RedisConfiguration : {[maxmemory-policy, allkeys-random], [maxclients, 7500], [maxmemory-reserved, 200],
131+
[maxfragmentationmemory-reserved, 300]...}
132+
EnableNonSslPort : False
133+
RedisVersion : 4.0.14
134+
Size : 6GB
135+
Sku : Premium
136+
SubnetId : /subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/mygroup/providers/Microsoft.Network/virtualNetworks/MyNet/subnets/MySubnet
137+
StaticIP : 10.0.0.4
138+
Tag : {}
139+
Zone : []
140+
```
141+
142+
### Example 5: Configure data persistence for a Premium Azure Cache for Redis
143+
144+
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.
145+
146+
After creating a storage account, get the storage account connection string using this procedure.
147+
148+
1. Run this command **Get-AzStorageAccountKey -ResourceGroupName $resourceGroupName -Name $storageAccountName** in powershell.
149+
1. From the output of above, copy any key.
150+
1. Put the storage account key and the storage account name in format below to get the connection string of your storage account.
151+
152+
Connection String Format :- "DefaultEndpointsProtocol=https;AccountName={storageAccountName};AccountKey={storageAccountKey};EndpointSuffix=core.windows.net"</br>
153+
154+
You must have the specific Redis configuration settings to enable data persistence.
155+
156+
For RDB backup enable
157+
- rdb-backup-enabled (Set true or false)
158+
- rdb-storage-connection-string (Give connection string in above format.)
159+
- rdb-backup-frequency (Set a backup interval in minutes. You can only choose from - 15, 30, 60, 360, 720 and 1440 minutes.)
160+
161+
```
162+
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"}
163+
164+
PrimaryKey : pJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
165+
SecondaryKey : sJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
166+
ResourceGroupName : MyGroup
167+
Id : /subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/mygroup/providers/Microsoft.Cache/Redis/MyCache
168+
Location : Central US
169+
Name : mycache
170+
Type : Microsoft.Cache/Redis
171+
HostName : mycache.redis.cache.windows.net
172+
Port : 6379
173+
ProvisioningState : creating
174+
SslPort : 6380
175+
RedisConfiguration : {[maxmemory-policy, allkeys-random], [maxclients, 7500], [maxmemory-reserved, 200],
176+
[maxfragmentationmemory-reserved, 300], [rdb-backup-enabled, true]....}
177+
EnableNonSslPort : False
178+
RedisVersion : 4.0.14
179+
Size : 6GB
180+
Sku : Premium
181+
Tag : {}
182+
Zone : []
183+
```
184+
185+
### Example 6: Configure data persistence for a Premium Azure Cache for Redis - AOF backup enabled
186+
187+
For AOF back up enabled.
188+
- aof-backup-enabled (Set true or false),
189+
- aof-storage-connection-string-0 (Give connection string in above format.)
190+
- 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.)
191+
192+
```
193+
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"}
194+
195+
PrimaryKey : pJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
196+
SecondaryKey : sJ+jruGKPHDKsEC8kmoybobH3TZx2njBR3ipEsquZFo=
197+
ResourceGroupName : MyGroup
198+
Id : /subscriptions/a559b6fd-3a84-40bb-a450-b0db5ed37dfe/resourceGroups/mygroup/providers/Microsoft.Cache/Redis/MyCache
199+
Location : Central US
200+
Name : mycache
201+
Type : Microsoft.Cache/Redis
202+
HostName : mycache.redis.cache.windows.net
203+
Port : 6379
204+
ProvisioningState : creating
205+
SslPort : 6380
206+
RedisConfiguration : {[maxmemory-policy, allkeys-random], [maxclients, 7500], [maxmemory-reserved, 200],
207+
[maxfragmentationmemory-reserved, 300], [aof-backup-enabled, true]...}
208+
EnableNonSslPort : False
209+
RedisVersion : 4.0.14
210+
Size : 6GB
211+
Sku : Premium
212+
Tag : {}
213+
Zone : []
214+
```
80215

81216
## PARAMETERS
82217

@@ -356,6 +491,9 @@ Accept wildcard characters: False
356491
```
357492
358493
### -SubnetId
494+
The full resource ID of a subnet in a virtual network to deploy the Azure Cache for Redis in.
495+
Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/{vnetName}/subnets/{subnetName}
496+
359497
```yaml
360498
Type: System.String
361499
Parameter Sets: (All)
@@ -399,7 +537,7 @@ Accept wildcard characters: False
399537
```
400538
401539
### -Zone
402-
List of zones.
540+
List of Azure regions with [Availability zones](https://docs.microsoft.com/en-us/azure/availability-zones/az-region#azure-services-supporting-availability-zones).
403541
404542
```yaml
405543
Type: System.String[]

0 commit comments

Comments
 (0)