
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
redis-entraid
Advanced tools
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:
You can learn more about managed identities in the Microsoft Entra ID documentation.
In this quick start guide, you will register an application and create a service principal in Azure. Then the following credentials are used to authenticate via Entra ID:
Create a Redis cache in Azure and grant your service principal access:
Settings/AuthenticationFurther details are available in the AMR or ACR documentation.
You need to install the redis-py Entra ID package via the following command:
pip install redis-entraid
The package depends on redis-py.
After having installed the package, you can import its modules:
from redis import Redis
from redis_entraid.cred_provider import *
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.).
Managed Identity
credential_provider = create_from_managed_identity(
identity_type=ManagedIdentityType.SYSTEM_ASSIGNED,
resource="https://redis.azure.com/"
)
Service principal
credential_provider = create_from_service_principal(
CLIENT_ID,
CLIENT_SECRET,
TENANT_ID
)
Default Azure Credential
credential_provider = create_from_default_azure_credential(
("https://redis.azure.com/.default",),
)
More examples available in examples folder.
The default configuration would be applied, but you're able to customise it.
credential_provider = create_from_service_principal(
CLIENT_ID,
CLIENT_SECRET,
TENANT_ID,
token_manager_config=TokenManagerConfig(
expiration_refresh_ratio=0.9,
lower_refresh_bound_millis=DEFAULT_LOWER_REFRESH_BOUND_MILLIS,
token_request_execution_timeout_in_ms=DEFAULT_TOKEN_REQUEST_EXECUTION_TIMEOUT_IN_MS,
retry_policy=RetryPolicy(
max_attempts=5,
delay_in_ms=50
)
)
)
You can test the credentials provider by obtaining a token. The following example demonstrates both, a synchronous and an asynchronous approach:
# Synchronous
credential_provider.get_credentials()
# Asynchronous
await credential_provider.get_credentials_async()
When using Entra ID, Azure enforces TLS on your Redis connection. Here is an example that shows how to test the connection in an insecure way:
client = Redis(host=HOST, port=PORT, ssl=True, ssl_cert_reqs=None, credential_provider=credential_provider)
print("The database size is: {}".format(client.dbsize()))
FAQs
Entra ID credentials provider implementation for Redis-py client
We found that redis-entraid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.