Connect a Pod to Azure Managed Redis
Authenticate an AKS workload to Azure Managed Redis with Microsoft Entra ID and keep long-lived Redis connections authenticated.
Learning status: Not practiced
The moving parts
Azure Managed Redis supports Microsoft Entra authentication, allowing an AKS workload to connect without storing a Redis access key. The pod obtains an Entra token through Workload ID, and the cache must be configured to accept that identity.
Authorize the workload identity
- Enable Microsoft Entra authentication for the cache.
- Add the user-assigned managed identity or service principal used by the pod to the cache's Microsoft Entra authentication configuration.
- Use the identity's principal ID (object ID) as the Redis username.
- Configure the client to request an Entra token for
https://redis.azure.com/.default(the documented resource GUID scope is also supported). - Connect with the username and access token using the Redis client's Entra authentication flow.
The Redis identity authorization is service-specific. A role on the AKS resource, a Kubernetes RoleBinding, or a Blob data role does not grant Redis command access.
Keep long-lived connections authenticated
Entra access tokens expire. A Redis client that keeps connections open must refresh the token and send AUTH again before the token expires. Without this refresh, an established connection can stop working even though Workload ID token acquisition initially succeeded.
Use a client library or integration that manages token refresh and re-authentication for the language and Redis client in use. For .NET with StackExchange.Redis, Microsoft provides Microsoft.Azure.StackExchangeRedis; for other client stacks, verify that their reconnect and re-authentication behavior covers token expiry.
If the cache uses private networking, confirm the pod can resolve and reach the cache endpoint through the configured network path. Diagnose token acquisition, cache-side identity authorization, and connectivity separately.
Source: Use Microsoft Entra for cache authentication with Azure Managed Redis.
Connects to