Note: redis-py-entraid 1.0.0 is the last version of redis-py that supports Python 3.9, as it has reached end of life. redis-py-entraid 1.1.0 supports Python 3.9+.
The redis-entraid Python package helps simplifying the authentication with Azure Managed Redis and Azure Cache for Redis using Microsoft Entra ID (formerly Azure Active Directory). It enables seamless integration with Azure's Redis services by fetching authentication tokens and managing the token renewal in the background. This package builds on top of redis-py and provides a structured way to authenticate by using a:
After having installed the package, you can import its modules:
from redis import Redis
from redis_entraid.cred_provider import *
Step 2 - Create the credential provider via the factory method
Following factory methods are offered depends on authentication type you need:
create_from_managed_identity - Creates a credential provider based on a managed identity.
Managed identities allow Azure services to authenticate without needing explicit credentials, as they are automatically assigned by Azure.
create_from_service_principal - Creates a credential provider using a service principal.
A service principal is typically used when you want to authenticate as an application, rather than as a user, with Azure Active Directory.
create_from_default_azure_credential - Creates a credential provider from a Default Azure Credential.
This method allows automatic selection of the appropriate credential mechanism based on the environment
(e.g., environment variables, managed identities, service principal, interactive browser etc.).
Use together with redis-entraid: extensions, drivers, servers and companion tools.
redisPythie’s Index: 96Python client for Redis database and key-value store254.7M downloads/mo
msalPythie’s Index: 90The Microsoft Authentication Library (MSAL) for Python library enables your app to access the Microsoft Cloud by supporting authentication of users with Microsoft Azure Active Directory accounts (AAD) and Microsoft Accounts (MSA) using industry standard OAuth2 and OpenID Connect.177.3M downloads/mo