I'm trying to create Azure Cache for Redis using Terraform.
I need to set a replica in the Redis configuration.
There are 3 terms that I come across in Azure portal:
- Replica count
- Shard Count ( Under
Redis Clustersection ) - Geo-Replication
I saw that Terraform supports these 3 parameters:
- replicas_per_master ( In ARM, replicasPerMaster )
- replicas_per_primary ( In ARM, replicasPerPrimary )
- shard_count ( In ARM, shardCount )
Which is the correct terraform configuration corresponding to set Replica count shown in Azure Portal?
ARM template for setting Replica count = 2 in portal, gives replicasPerMaster: 2
So I decided to go with replicas_per_master = 2 in Terraform. Should I set replicas_per_primary also to 2?
What is the difference between these options?

Azure Cache for Redis uses the settings
replicas_per_masterandreplicas_per_primaryto set up replication, but they work for different situations in the service. This is how they are different:replicas_per_master: This setting applies to Azure Cache for Redis instances that do not use clustering. It lets you specify the number of replicas for each master node. This way, the cache can fail over to a replica if the master node fails, which improves the cache's availability.replicas_per_primary: This setting applies to Azure Cache for Redis instances that have clustering enabled. Clustering partitions the Redis data into multiple shards, each with a primary node and optionally one or more replicas. Thereplicas_per_primarysetting determines the number of replicas for each primary node in a shard.The number of shards and replicas depends on whether you have clustering enabled or not. With clustering enabled, you can use
shard_countto set the number of shards andreplicas_per_primaryto set the number of replicas for each shard. Without clustering, you only need to usereplicas_per_masterto set the number of replicas for the master node.If you are not using clustering, you probably do not need to set
replicas_per_primary. This setting is only relevant for clustered configurations. Since you said that settingreplicas_per_masterto 2 worked for you, this seems to be your case.The settings for non-clustered and clustered caches are different. For a non-clustered cache, you only need to specify
replicas_per_master. For a clustered cache, which requires a Premium SKU, you may need to specify bothshard_countandreplicas_per_primary. Do not usereplicas_per_masterfor a clustered cache.My demo terraform configuration:
Output: