diff --git a/.github/wordlist.txt b/.github/wordlist.txt index ce4926e..c082707 100644 --- a/.github/wordlist.txt +++ b/.github/wordlist.txt @@ -56,3 +56,7 @@ validator validators virtualenv http +AMR +EntraID +entraid +metamodel \ No newline at end of file diff --git a/README.md b/README.md index 5bd4a4f..71b625c 100644 --- a/README.md +++ b/README.md @@ -370,6 +370,36 @@ You can run these modules in your self-hosted Redis deployment, or you can use [ To learn more, read [our documentation](docs/redis_modules.md). +## Connecting to Azure Managed Redis with EntraID + +Once you have EntraID setup for your Azure Managed Redis (AMR) deployment, you can use Redis OM Python with it by leveraging the [redis-py-entraid](https://github.com/redis/redis-py-entraid) library. +Simply install the library with: + +``` +pip install redis-entraid +``` + +Then you'll initialize your credentials provider, connect to redis, and pass the database object into your metamodel: + +```python + +from redis import Redis +from redis_entraid.cred_provider import create_from_default_azure_credential +from redis_om import HashModel, Field +credential_provider = create_from_default_azure_credential( + ("https://redis.azure.com/.default",), + ) + +db = Redis(host="cluster-name.region.redis.azure.net", port=10000, ssl=True, ssl_cert_reqs=None, credential_provider=credential_provider) +db.flushdb() +class User(HashModel): + first_name: str + last_name: str = Field(index=True) + + class Meta: + database = db +``` + ## ❤️ Contributing We'd love your contributions!