Managed Redis
Introduction
Section titled “Introduction”Azure Managed Redis is a managed in-memory data store built on Redis Enterprise software. Applications use it as a cache, a session store, a vector and document store through its modules, and a message broker. A cluster serves one database, named default, that clients reach with standard Redis clients. For more information, see What is Azure Managed Redis?
LocalStack for Azure provides a local environment for building and testing applications that use Azure Managed Redis. Each database you create is backed by a real Redis server running in its own container, so your application runs its own Redis commands, with the same clients, against a real Redis engine. The database serves TLS or plaintext, as its client protocol sets, authenticates clients with access keys or with Microsoft Entra ID through access policy assignments, loads the modules you enable at creation, and enforces the cluster’s public network access setting.
The supported APIs are listed in the API Coverage section.
Getting started
Section titled “Getting started”This guide is designed for users new to Azure Managed Redis and assumes basic knowledge of the Azure CLI, our lstk az proxy, and redis-cli.
Launch LocalStack using your preferred method. For more information, see Introduction to LocalStack for Azure. Once the container is running, enable Azure CLI interception by running:
lstk az start-interceptionThis command points the az CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API.
To revert this configuration, run:
lstk az stop-interceptionThis reconfigures the az CLI to send commands to the official Azure management REST API.
Create a resource group
Section titled “Create a resource group”Create a resource group to contain your cluster:
az group create \ --name rg-managed-redis-demo \ --location westeurope{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-managed-redis-demo", "location": "westeurope", "name": "rg-managed-redis-demo", "properties": { "provisioningState": "Succeeded" }, ...}Create a cluster
Section titled “Create a cluster”Create a Balanced B0 cluster and its default database in one command. The database serves TLS, authenticates with access keys, and loads the RedisJSON module:
az redisenterprise create \ --cluster-name managed-redis-demo \ --resource-group rg-managed-redis-demo \ --location westeurope \ --sku Balanced_B0 \ --high-availability Disabled \ --public-network-access Enabled \ --access-keys-authentication Enabled \ --client-protocol Encrypted \ --clustering-policy EnterpriseCluster \ --modules name=RedisJSON{ "accessKeysAuthentication": "Enabled", "clientProtocol": "Encrypted", "clusteringPolicy": "EnterpriseCluster", "deferUpgrade": "NotDeferred", "evictionPolicy": "VolatileLRU", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-managed-redis-demo/providers/Microsoft.Cache/redisEnterprise/managed-redis-demo/databases/default", "modules": [ { "args": "", "name": "RedisJSON", "version": "8.2.9" } ], "name": "default", "port": 4510, "provisioningState": "Succeeded", "redisVersion": "7.4", "resourceGroup": "rg-managed-redis-demo", "resourceState": "Running", "type": "Microsoft.Cache/redisEnterprise/databases"}Show the cluster’s host name:
az redisenterprise show \ --cluster-name managed-redis-demo \ --resource-group rg-managed-redis-demo \ --query "{hostName:hostName, sku:sku.name, provisioningState:provisioningState, resourceState:resourceState}"{ "hostName": "managed-redis-demo.redis.azure.localhost.localstack.cloud", "provisioningState": "Succeeded", "resourceState": "Running", "sku": "Balanced_B0"}Show the database’s port and settings:
az redisenterprise database show \ --cluster-name managed-redis-demo \ --resource-group rg-managed-redis-demo \ --query "{port:port, clientProtocol:clientProtocol, clusteringPolicy:clusteringPolicy, modules:modules[].name, accessKeysAuthentication:accessKeysAuthentication}"{ "accessKeysAuthentication": "Enabled", "clientProtocol": "Encrypted", "clusteringPolicy": "EnterpriseCluster", "modules": [ "RedisJSON" ], "port": 4510}The host name is an emulator host name rather than managed-redis-demo.westeurope.redis.azure.net, and the port is a port the emulator assigns to the database rather than 10000.
Connect with an access key
Section titled “Connect with an access key”Capture the host name, the port, and the primary access key. redis-cli reads its password from the REDISCLI_AUTH environment variable:
export REDIS_HOST=$(az redisenterprise show --cluster-name managed-redis-demo --resource-group rg-managed-redis-demo --query hostName --output tsv)export REDIS_PORT=$(az redisenterprise database show --cluster-name managed-redis-demo --resource-group rg-managed-redis-demo --query port --output tsv)export REDISCLI_AUTH=$(az redisenterprise database list-keys --cluster-name managed-redis-demo --resource-group rg-managed-redis-demo --query primaryKey --output tsv)Connect over TLS, then store and read a JSON document with the RedisJSON module:
redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" --tls PINGredis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" --tls JSON.SET product:1 '$' '{"name":"Widget","price":19.99}'redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" --tls JSON.GET product:1 '$.name'PONGOK["Widget"]The database presents the LocalStack public certificate, whose *.redis.azure.localhost.localstack.cloud entry covers the host name, so redis-cli and other clients verify the server against the public roots they already trust, as they do against Azure.
When LocalStack cannot download that certificate, for example with SKIP_SSL_CERT_DOWNLOAD=1 or without outbound network access, the database presents a certificate issued by the LocalStack root certificate authority instead, and a client needs that authority, for example with redis-cli --cacert.
Regenerate the secondary key. The primary key, and the sessions authenticated with it, stay valid:
az redisenterprise database regenerate-key \ --cluster-name managed-redis-demo \ --resource-group rg-managed-redis-demo \ --key-type Secondary \ --output noneConnect with Microsoft Entra ID
Section titled “Connect with Microsoft Entra ID”With Microsoft Entra authentication, the Redis user name is the object ID of your user or service principal, and the password is an access token for https://redis.azure.com.
Get a token, and read your object ID from its oid claim:
export REDIS_TOKEN=$(az account get-access-token --resource https://redis.azure.com --query accessToken --output tsv)export PRINCIPAL_ID=$(python3 -c 'import base64, json, os; payload = os.environ["REDIS_TOKEN"].split(".")[1]; print(json.loads(base64.urlsafe_b64decode(payload + "=" * (-len(payload) % 4)))["oid"])')Assign the default access policy to that object ID:
az redisenterprise database access-policy-assignment create \ --cluster-name managed-redis-demo \ --resource-group rg-managed-redis-demo \ --database-name default \ --name demo-user \ --access-policy-name default \ --object-id "$PRINCIPAL_ID" \ --query "{name:name, accessPolicyName:accessPolicyName, provisioningState:provisioningState}"{ "accessPolicyName": "default", "name": "demo-user", "provisioningState": "Succeeded"}Connect with the object ID and the token:
REDISCLI_AUTH="$REDIS_TOKEN" redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" --tls --user "$PRINCIPAL_ID" JSON.GET product:1 '$.price'[19.99]List the SKUs the cluster can scale to
Section titled “List the SKUs the cluster can scale to”List the Balanced SKUs the cluster can scale to:
az redisenterprise list-skus-for-scaling \ --cluster-name managed-redis-demo \ --resource-group rg-managed-redis-demo \ --query "skus[?starts_with(name, 'Balanced_')].{name:name, sizeInGB:sizeInGB}" \ --output tableName SizeInGB-------------- ----------Balanced_B0 0.5Balanced_B1 1.0Balanced_B3 3.0Balanced_B5 6.0Balanced_B10 12.0Balanced_B20 24.0Balanced_B50 60.0Balanced_B100 120.0Balanced_B150 175.0Balanced_B250 235.0Balanced_B350 350.0Balanced_B500 480.0Balanced_B700 720.0Balanced_B1000 960.0Flush the database
Section titled “Flush the database”Flush the database to remove every key:
az redisenterprise database flush \ --cluster-name managed-redis-demo \ --resource-group rg-managed-redis-demoredis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" --tls DBSIZE0Delete the cluster
Section titled “Delete the cluster”Delete the cluster and the resource group:
az redisenterprise delete \ --cluster-name managed-redis-demo \ --resource-group rg-managed-redis-demo \ --yesaz group delete \ --name rg-managed-redis-demo \ --yesFeatures
Section titled “Features”- Cluster lifecycle: Create, show, list, update, and delete clusters in the Memory Optimized, Balanced, Compute Optimized, and Flash Optimized tiers. An update changes the tags, the SKU, the public network access setting, and the minimum TLS version, and can turn high availability on but not off.
- Default database: Create the
defaultdatabase with its client protocol, clustering policy, eviction policy, modules, access key setting, and upgrade deferral, show and list it, update its eviction policy, access key setting, and upgrade deferral, and delete it. - Real Redis server: Each database runs a Redis server in its own container, so clients connect with the Redis protocol and run Redis commands against a real Redis engine.
- TLS and plaintext: A database with the
Encryptedclient protocol serves TLS, with a certificate that covers its host name, and a database with thePlaintextclient protocol serves plaintext. - Access keys: Clients authenticate with the primary or the secondary key. Regenerating a key replaces only that key. Disabling access key authentication closes the sessions authenticated with a key and keeps the Microsoft Entra sessions, and enabling it again issues two new keys.
- Microsoft Entra authentication: Access policy assignments grant a user or a service principal the
defaultaccess policy. The client authenticates with its object ID and an access token forhttps://redis.azure.com, and deleting the assignment revokes the access. - Modules: A database loads the RediSearch, RedisJSON, RedisBloom, and RedisTimeSeries modules you enable when you create it. The commands of a module the database doesn’t load answer
unknown command. RediSearch requires theEnterpriseClusterorNoClusterclustering policy, and a Flash Optimized cluster offers only RedisJSON. - Clustering policies: The
EnterpriseClusterandNoClusterpolicies present a single endpoint, and theOSSClusterpolicy presents the Redis Cluster protocol to cluster-aware clients. ANoClusterdatabase can move toEnterpriseClusterorOSSClusterand keeps its data and keys. - Public network access: Setting the cluster’s
publicNetworkAccesstoDisabledrefuses new connections and closes existing ones. - Scaling: List the SKUs a cluster can scale to, and change its SKU. A cluster can’t scale between the in-memory tiers and Flash Optimized, or before its database exists.
- Flush: Flush the database to remove every key.
Limitations
Section titled “Limitations”- One Redis server per database: A database has no shards and no replica, whatever its SKU and its
highAvailabilitysetting. With theOSSClusterpolicy, one Redis node holds every hash slot. - Redis 8.2: Every database runs Redis 8.2 and its modules, the version Azure Managed Redis offers in preview, although it reports
redisVersion7.4, the version Azure creates by default. Commands added after Redis 7.4 work locally but fail on a Redis 7.4 database in Azure. - Module arguments: A database applies
MAXSEARCHRESULTSfor RediSearch,ERROR_RATEandINITIAL_SIZEfor RedisBloom, andRETENTION_POLICYfor RedisTimeSeries, and refuses any other module argument. - Memory size isn’t enforced: The SKU’s size sets no memory limit, so the eviction policy never evicts.
- Unsupported features: Active geo-replication and linked databases, import and export, data persistence, customer-managed keys, Private Link, migration from Azure Cache for Redis, the
notifyKeyspaceEventssetting, and Redis version upgrades are not supported.
Samples
Section titled “Samples”Explore end-to-end examples in the LocalStack for Azure Samples repository.
API Coverage
Section titled “API Coverage”20 of 31 operations implemented
| Operation ▲ | Implemented ▼ |
|---|