- Knowledge Base
- Microsoft Azure
- Redis Cache
- Enable Geo-Replication for Azure Cache for Redis Servers
To ensure business continuity and minimizes data loss in the event of a regional outage affecting the primary cache, enable and configure geo-replication for your Microsoft Azure Cache for Redis servers.
Geo-replication establishes a primary-secondary relationship between Azure Cache for Redis instances, often in different Azure regions, where the primary handles read/write operations and replicates changes to the secondary. Primarily designed for cross-region disaster recovery, this links two Premium tier caches, ensuring data replication from the active primary to the passive secondary. In the event of a primary region outage, a manual failover process involves unlinking the secondary and redirecting application traffic to it for continued read/write access.
Geo-replication is not currently available for the Azure Cache for Redis servers in the Basic and Standard tiers.
Audit
To determine if geo-replication is enabled for your Microsoft Azure Cache for Redis servers, perform the following operations:
Using Azure Portal
01 Sign in to the Microsoft Azure Portal.
02 Navigate to All resources blade available at https://portal.azure.com/#browse/all to access all your Microsoft Azure cloud resources.
03 Choose the Azure subscription that you want to access from the Subscription equals all filter box and choose Apply.
04 From the Type equals all filter box, select Type for Filter, Equals for Operator, and Azure Cache for Redis for Value, then choose Apply to list the Azure Cache for Redis servers available in the selected subscription.
05 Click on the name (link) of the Azure Cache for Redis server that you want to examine.
06 In the resource navigation panel, under Settings, select Geo-replication to access the cache replication settings available for the selected server.
07 On the Geo-replication page, check for any cache replication links configured for your cache server. If there are no cache replication links listed on the Geo-replication and the following message is displayed: No results, geo-replication is not enabled for the selected Microsoft Azure Cache for Redis server.
08 Repeat steps no. 5 - 7 for each Azure Cache for Redis server deployed in the selected Azure subscription.
09 Repeat steps no. 3 – 8 for each Azure subscription created in your Microsoft Azure cloud account.
Using Azure CLI
01 Run account list command (Windows/macOS/Linux) with custom output filters to list the IDs of the cloud subscriptions available in your Azure cloud account:
az account list --query '[*].id'
02 The command output should return the requested subscription identifiers (IDs):
[ "abcdabcd-1234-abcd-1234-abcdabcdabcd", "abcd1234-abcd-1234-abcd-abcd1234abcd" ]
03 Run account set command (Windows/macOS/Linux) with the ID of the Azure cloud subscription that you want to examine as the identifier parameter to set the selected subscription to be the current active subscription (the command does not produce an output):
az account set --subscription abcdabcd-1234-abcd-1234-abcdabcdabcd
04 Run redis list command (Windows/macOS/Linux) with custom output filters to list the name and the associated resource group for each Azure Cache for Redis server available in the selected subscription:
az redis list --output table --query '[*].{name:name, resourceGroup:resourceGroup}'
05 The command output should return the requested cache server identifiers:
Name ResourceGroup ------------------------- ------------------------------ cc-project5-redis-cache cloud-shell-storage-westeurope cc-main-app-redis-cache cloud-shell-storage-westeurope
06 Run redis server-link list command (Windows/macOS/Linux) with the name of the Azure Cache for Redis server that you want to examine as the identifier parameter, to list the name of each linked replication server associated with the selected Redis cache server:
az redis server-link list --name cc-project5-redis-cache --resource-group cloud-shell-storage-westeurope --query '[].name'
07 The command output should return the names of the linked servers associated with the selected cache server:
[]
If the redis server-link list command output returns an empty array, i.e., [], there are no replication servers linked to your cache server, therefore, geo-replication is not enabled for the selected Microsoft Azure Cache for Redis server.
08 Repeat step no. 6 and 7 for each Azure Cache for Redis server available within the current Azure subscription.
09 Repeat steps no. 3 – 8 for each Azure subscription created in your Microsoft Azure cloud account.
Remediation / Resolution
Geo-replication is designed as an efficient disaster-recovery solution. To enable geo-replication for your Microsoft Azure Cache for Redis servers, perform the following operations:
Using Azure Portal
01 Sign in to the Microsoft Azure Portal.
02 Navigate to All resources blade available at https://portal.azure.com/#browse/all to access all your Microsoft Azure cloud resources.
03 Choose the Azure subscription that you want to access from the Subscription equals all filter box and choose Apply.
04 From the Type equals all filter box, select Type for Filter, Equals for Operator, and Azure Cache for Redis for Value, then choose Apply to list only the Azure Cache for Redis servers available in the selected subscription.
05 Click on the name (link) of the Redis cache server that you want to geo-replicate and collect all relevant configuration information.
06 Navigate to Azure Cache for Redis blade at https://portal.azure.com/#browse/Microsoft.Cache%2FRedis, choose Create, select Azure Cache for Redis, and perform the following actions to create the Redis cache server required for replication (i.e., geo-secondary cache server):
- For Basics, provide the following information:
- For Subscription, choose your Azure subscription (must match the subscription of the geo-primary cache).
- For Resource group, select the correct resource group (must match the resource group of the geo-primary cache).
- Provide a unique name for the new cache server in the Name box.
- For Region, select the Azure cloud region where the geo-secondary cache server will be deployed.
- For Cache SKU (View full pricing details), choose Premium (up to 99.9% availability) from the Azure Cache for Redis list. Both cache servers must Premium tier caches.
- For Cache size, choose the cache instance size for the new cache server (must match the resource group of the geo-primary cache).
- Choose Next : Networking > to continue the setup process.
- For Networking, perform the following operations:
- For Connectivity method, choose Private Endpoint (Recommended) to disable public access and use private access from one or more virtual networks.
- For Private endpoint, choose Add private endpoint and follow the steps outlined on this page to create a new private endpoint connection.
- Choose Next : Advanced > to continue the setup process.
- For Advanced, use the information collected at step no. 5 to configure the resource settings to match the geo-primary cache server configuration. Both caches must use the same version of Redis and should have only one replica per primary per shard. Choose Next : Tags > to continue the setup.
- For Tags, use the Name, Value, and Resource fields to create tags that will help organize the identity of the new resource. Choose Next : Review + create > to validate the setup.
- For Review + create, review the resource configuration details, then choose Create to create your new geo-secondary cache server.
07 Navigate back to the Azure Cache for Redis listing page and click on the name (link) of the Redis cache server that you want to configure for replication.
08 In the resource navigation panel, under Settings, select Geo-replication to access the cache replication settings available for the selected server.
09 Choose Add cache replication link, select the geo-secondary cache server created in step no. 6 from the Compatible caches list, and choose Link to link the two cache servers together and begin the replication process. Once the replication process is complete, the Link provisioning status should be set to Succeeded.
10 (Optional) To initiate a failover from the geo-primary cache to the geo-secondary, choose Failover from the page top menu, and select Yes for confirmation.
11 Repeat steps no. 5 – 9 for each Azure Cache for Redis server that you want to configure, available within the selected subscription.
12 Repeat steps no. 3 – 11 for each Azure subscription created in your Microsoft Azure cloud account.
Using Azure CLI
01 Run account list command (Windows/macOS/Linux) with custom output filters to list the IDs of the cloud subscriptions available in your Azure cloud account:
az account list --query '[*].id'
02 The command output should return the requested subscription identifiers (IDs):
[ "abcdabcd-1234-abcd-1234-abcdabcdabcd", "abcd1234-abcd-1234-abcd-abcd1234abcd" ]
03 Run account set command (Windows/macOS/Linux) with the ID of the Azure cloud subscription that you want to examine as the identifier parameter to set the selected subscription to be the current active subscription (the command does not produce an output):
az account set --subscription abcdabcd-1234-abcd-1234-abcdabcdabcd
04 Run redis show command (Windows/macOS/Linux) with custom output filters to describe the configuration information available for the Azure Cache for Redis server that you want to geo-replicate:
az redis show --name cc-project5-redis-cache --resource-group cloud-shell-storage-westeurope
05 The command output should return the requested configuration information:
{ "accessKeys": null, "disableAccessKeyAuthentication": false, "enableNonSslPort": false, "linkedServers": [], "location": "West Europe", "minimumTlsVersion": "1.2", "name": "cc-project5-redis-cache", "port": 6379, "privateEndpointConnections": null, "provisioningState": "Succeeded", "publicNetworkAccess": "Enabled", ... "redisVersion": "6.0", "resourceGroup": "cloud-shell-storage-westeurope", "shardCount": null, "sku": { "capacity": 1, "family": "P", "name": "Premium" }, "sslPort": 6380, "staticIp": "10.0.0.10", "type": "Microsoft.Cache/Redis", "updateChannel": "Stable" }
06 Run redis create command (Windows/macOS/Linux) to create the Azure Cache for Redis server required for replication (i.e., geo-secondary cache server):
az redis create --name cc-project5-geo-secondary-cache --resource-group cloud-shell-storage-westeurope --location westeurope --sku Premium --vm-size p1 --mi-system-assigned --update-channel Stable
07 The command output should return the configuration information available for the new cache server:
{ "hostName": "cc-project5-geo-secondary-cache.redis.cache.windows.net", "linkedServers": [], "location": "West Europe", "minimumTlsVersion": "1.2", "name": "cc-project5-geo-secondary-cache", "port": 6379, "privateEndpointConnections": null, "provisioningState": "Succeeded", "publicNetworkAccess": "Enabled", ... "resourceGroup": "cloud-shell-storage-westeurope", "sku": { "capacity": 1, "family": "P", "name": "Premium" }, "sslPort": 6380, "staticIp": "10.0.0.15", "type": "Microsoft.Cache/Redis", "updateChannel": "Stable" }
08 Run redis server-link create command (Windows/macOS/Linux) to create a cache replication link for the geo-primary cache server specified by the --name parameter. For the --server-to-link parameter, specify the name of the geo-secondary cache server created in step no. 8:
az redis server-link create --name cc-project5-redis-cache --replication-role Secondary --resource-group cloud-shell-storage-westeurope --server-to-link cc-project5-geo-secondary-cache
09 The command output should return the configuration information available for the new cache server link:
{ "geoReplicatedPrimaryHostName": "cc-project5-geo-secondary-cache.geo.redis.cache.windows.net", "id": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Cache/Redis/cc-project5-redis-cache/linkedServers/cc-project5-geo-secondary", "linkedRedisCacheId": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Cache/Redis/cc-project5-geo-secondary-cache", "linkedRedisCacheLocation": "West Europe", "name": "cc-project5-geo-secondary-cache", "primaryHostName": "cc-project5-redis-cache.redis.cache.windows.net", "provisioningState": "Succeeded", "resourceGroup": "cloud-shell-storage-westeurope", "serverRole": "Secondary", "type": "Microsoft.Cache/Redis/linkedServers" }
10 Repeat steps no. 4 - 9 for each Azure Cache for Redis server that you want to configure, available in the selected subscription.
11 Repeat steps no. 3 – 10 for each Azure subscription created in your Microsoft Azure cloud account.
References
- Azure Official Documentation
- High availability and disaster recovery
- Configure passive geo-replication for Premium Azure Cache for Redis instances
- Azure Command Line Interface (CLI) Documentation
- az account list
- az account set
- az redis list
- az redis server-link list
- az redis server-link create
Related RedisCache rules
- Enable Geo-Replication for Azure Cache for Redis Servers (Reliability)
- Enable Data Persistence for Azure Cache for Redis Servers (Reliability)
- Configure Preferred Maintenance Window for Scheduled Updates (Reliability)
- Enable Diagnostic Logs for Azure Cache for Redis Servers (Security, reliability, operational-excellence, cost-optimisation, performance-efficiency)