Cache for Redis

Microsoft Azure
Azure Cache for Redis is a fully-managed, in-memory data store that supports caching and data storage scenarios. It is based on the popular open-source Redis database and is designed to provide fast and scalable access to data, with low-latency and high-throughput performance. Azure Cache for Redis is a distributed cache service that can be used to store and access data in memory, reducing the need for costly database queries or expensive disk-based storage. It supports various data structures, such as strings, hashes, sets, sorted sets, and lists, and provides features such as expiration, eviction, transactions, and Lua scripting. Azure Cache for Redis can be used in a wide range of scenarios, such as session management, gaming, e-commerce, media streaming, and IoT, among others. It can also be integrated with other Azure services, such as Azure Functions, Azure Web Apps, and Azure Virtual Machines, and supports multiple clients and protocols, including Redis clients, .NET libraries, and REST APIs.‍
Terraform Name
Cache for Redis

The following arguments are supported:

  • name - (Required) The name of the Redis instance. Changing this forces a new resource to be created.
  • location - (Required) The location of the resource group. Changing this forces a new resource to be created.
  • resource_group_name - (Required) The name of the resource group in which to create the Redis instance. Changing this forces a new resource to be created.
  • capacity - (Required) The size of the Redis cache to deploy. Valid values for a SKU family of C (Basic/Standard) are 0, 1, 2, 3, 4, 5, 6, and for P (Premium) family are 1, 2, 3, 4, 5.
  • family - (Required) The SKU family/pricing group to use. Valid values are C (for Basic/Standard SKU family) and P (for Premium)
  • sku_name - (Required) The SKU of Redis to use. Possible values are Basic, Standard and Premium.


Downgrading the SKU will force a new resource to be created.

  • enable_non_ssl_port - (Optional) Enable the non-SSL port (6379) - disabled by default.
  • identity - (Optional) An identity block as defined below.
  • minimum_tls_version - (Optional) The minimum TLS version. Possible values are 1.0, 1.1 and 1.2. Defaults to 1.0.
  • patch_schedule - (Optional) A list of patch_schedule blocks as defined below.
  • private_static_ip_address - (Optional) The Static IP Address to assign to the Redis Cache when hosted inside the Virtual Network. This argument implies the use of subnet_id. Changing this forces a new resource to be created.
  • public_network_access_enabled - (Optional) Whether or not public network access is allowed for this Redis Cache. true means this resource could be accessed by both public and private endpoint. false means only private endpoint access is allowed. Defaults to true.
  • redis_configuration - (Optional) A redis_configuration as defined below - with some limitations by SKU - defaults/details are shown below.
  • replicas_per_master - (Optional) Amount of replicas to create per master for this Redis Cache.


Configuring the number of replicas per master is only available when using the Premium SKU and cannot be used in conjunction with shards.

  • replicas_per_primary - (Optional) Amount of replicas to create per primary for this Redis Cache. If both replicas_per_primary and replicas_per_master are set, they need to be equal.
  • redis_version - (Optional) Redis version. Only major version needed. Valid values: 4, 6.
  • tenant_settings - (Optional) A mapping of tenant settings to assign to the resource.
  • shard_count - (Optional) Only available when using the Premium SKU The number of Shards to create on the Redis Cluster.
  • subnet_id - (Optional) Only available when using the Premium SKU The ID of the Subnet within which the Redis Cache should be deployed. This Subnet must only contain Azure Cache for Redis instances without any other type of resources. Changing this forces a new resource to be created.
  • tags - (Optional) A mapping of tags to assign to the resource.
  • zones - (Optional) Specifies a list of Availability Zones in which this Redis Cache should be located. Changing this forces a new Redis Cache to be created.

Please Note

: Availability Zones are in Preview and only supported in several regions at this time - as such you must be opted into the Preview to use this functionality. You can opt into the Availability Zones Preview in the Azure Portal.

An identity block supports the following:

  • type - (Required) Specifies the type of Managed Service Identity that should be configured on this Redis Cluster. Possible values are SystemAssigned, UserAssigned, SystemAssigned, UserAssigned (to enable both).
  • identity_ids - (Optional) A list of User Assigned Managed Identity IDs to be assigned to this Redis Cluster.


This is required when type is set to UserAssigned or SystemAssigned, UserAssigned.

A redis_configuration block supports the following:

  • aof_backup_enabled - (Optional) Enable or disable AOF persistence for this Redis Cache. Defaults to false.
  • aof_storage_connection_string_0 - (Optional) First Storage Account connection string for AOF persistence.
  • aof_storage_connection_string_1 - (Optional) Second Storage Account connection string for AOF persistence.

Example usage:

redis_configuration {
aof_backup_enabled = true
aof_storage_connection_string_0 = "DefaultEndpointsProtocol=https;
aof_storage_connection_string_1 = "DefaultEndpointsProtocol=https;

  • enable_authentication - (Optional) If set to false, the Redis instance will be accessible without authentication. Defaults to true.


enable_authentication can only be set to false if a subnet_id is specified; and only works if there aren't existing instances within
the subnet with enable_authentication set to true.

  • maxmemory_reserved - (Optional) Value in megabytes reserved for non-cache usage e.g. failover. Defaults are shown below.
  • maxmemory_delta - (Optional) The max-memory delta for this Redis instance. Defaults are shown below.
  • maxmemory_policy - (Optional) How Redis will select what to remove when maxmemory is reached. Defaults are shown below. Defaults to volatile-lru.
  • maxfragmentationmemory_reserved - (Optional) Value in megabytes reserved to accommodate for memory fragmentation. Defaults are shown below.
  • rdb_backup_enabled - (Optional) Is Backup Enabled? Only supported on Premium SKUs. Defaults to false.


If rdb_backup_enabled set to true, rdb_storage_connection_string must also be set.

  • rdb_backup_frequency - (Optional) The Backup Frequency in Minutes. Only supported on Premium SKUs. Possible values are: 15, 30, 60, 360, 720 and 1440.
  • rdb_backup_max_snapshot_count - (Optional) The maximum number of snapshots to create as a backup. Only supported for Premium SKUs.
  • rdb_storage_connection_string - (Optional) The Connection String to the Storage Account. Only supported for Premium SKUs. In the format: DefaultEndpointsProtocol=https;BlobEndpoint=${azurerm_storage_account.example.primary_blob_endpoint};


There's a bug in the Redis API where the original storage connection string isn't being returned, which is being tracked in this issue. In the interim you can use the ignore_changes attribute to ignore changes to this field e.g.:

resource "azurerm_redis_cache" "example" {
 # ...
 ignore_changes = [redis_configuration.0.rdb_storage_connection_string]

  • notify_keyspace_events - (Optional) Keyspace notifications allows clients to subscribe to Pub/Sub channels in order to receive events affecting the Redis data set in some way. Reference

redis_configuration {
 maxmemory_reserved = 10
 maxmemory_delta    = 2
 maxmemory_policy   = "allkeys-lru"

Default Redis Configuration Values

Redis ValueBasicStandardPremiumenable_authenticationtruetruetruemaxmemory_reserved250200maxfragmentationmemory_


The maxmemory_reserved, maxmemory_delta and maxfragmentationmemory_reserved settings are only available for Standard and Premium caches.
More details are available in the Relevant Links section below.

A patch_schedule block supports the following:

  • day_of_week - (Required) the Weekday name - possible values include Monday, Tuesday, Wednesday etc.
  • start_hour_utc - (Optional) the Start Hour for maintenance in UTC - possible values range from 0 - 23.


The Patch Window lasts for 5 hours from the start_hour_utc.

  • maintenance_window - (Optional) The ISO 8601 timespan which specifies the amount of time the Redis Cache can be updated. Defaults to PT5H.

Associating resources with a
Cache for Redis
Resources do not "belong" to a
Cache for Redis
Rather, one or more Security Groups are associated to a resource.
Cache for Redis
via Terraform:
The following HCL provisions a Standard Redis Cache

resource "azurerm_resource_group" "example" {
 name     = "example-resources"
 location = "West Europe"

# NOTE: the Name used for Redis needs to be globally unique
resource "azurerm_redis_cache" "example" {
 name                = "example-cache"
 location            = azurerm_resource_group.example.location
 resource_group_name =
 capacity            = 2
 family              = "C"
 sku_name            = "Standard"
 enable_non_ssl_port = false
 minimum_tls_version = "1.2"

 redis_configuration {

Cache for Redis
via CLI:

az redis create --location
               --sku {Basic, Premium, Standard}
               --vm-size {c0, c1, c2, c3, c4, c5, c6, p1, p2, p3, p4, p5}
               [--minimum-tls-version {1.0, 1.1, 1.2}]
               [--zones {1, 2, 3}]


az redis create --location westus2 --name MyRedisCache --resource-group MyResourceGroup --sku Basic --vm-size c0

aws cost
Direct Cost
Indirect Cost
No items found.
Best Practices for
Cache for Redis

Categorized by Availability, Security & Compliance and Cost

Access allowed from VPN
No items found.
Auto Scaling Group not in use
No items found.
Connections towards DynamoDB should be via VPC endpoints
No items found.
Container in CrashLoopBackOff state
No items found.
EC2 with GPU capabilities
No items found.
EC2 with high privileged policies
No items found.
ECS cluster delete alarm
No items found.
ECS task with Admin access (*:*)
ECS task with high privileged policies
No items found.
EKS cluster delete alarm
No items found.
ElastiCache cluster delete alarm
No items found.
Ensure Container liveness probe is configured
No items found.
Ensure ECS task definition has memory limit
No items found.
Ensure EMR cluster master nodes are not publicly accessible
No items found.
More from
Microsoft Azure