From afd90493421b1f5222f552e693c2c0d531078d16 Mon Sep 17 00:00:00 2001 From: slorello89 Date: Wed, 9 Apr 2025 16:58:40 -0400 Subject: [PATCH 1/4] Adding EntraID explainer to README --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 5bd4a4f..e04dbca 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-naem.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! From 80ff497ce163ae914a4bfd7764e5e0883fc0b418 Mon Sep 17 00:00:00 2001 From: Andrew Brookins Date: Wed, 9 Apr 2025 18:26:25 -0700 Subject: [PATCH 2/4] Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e04dbca..71b625c 100644 --- a/README.md +++ b/README.md @@ -390,7 +390,7 @@ credential_provider = create_from_default_azure_credential( ("https://redis.azure.com/.default",), ) -db = Redis(host="cluster-naem.region.redis.azure.net", port=10000, ssl=True, ssl_cert_reqs=None, credential_provider=credential_provider) +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 From c5c56a214fe51e2402b13e16c234c62dfaccee2b Mon Sep 17 00:00:00 2001 From: slorello89 Date: Wed, 9 Apr 2025 22:15:29 -0400 Subject: [PATCH 3/4] spellcheck --- .github/wordlist.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/wordlist.txt b/.github/wordlist.txt index ce4926e..14389ed 100644 --- a/.github/wordlist.txt +++ b/.github/wordlist.txt @@ -56,3 +56,6 @@ validator validators virtualenv http +AMR +EntraID +entraid \ No newline at end of file From 2043b198835a41fbca8262139714f332b2ba3e23 Mon Sep 17 00:00:00 2001 From: slorello89 Date: Wed, 9 Apr 2025 22:17:00 -0400 Subject: [PATCH 4/4] spellcheck --- .github/wordlist.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/wordlist.txt b/.github/wordlist.txt index 14389ed..c082707 100644 --- a/.github/wordlist.txt +++ b/.github/wordlist.txt @@ -58,4 +58,5 @@ virtualenv http AMR EntraID -entraid \ No newline at end of file +entraid +metamodel \ No newline at end of file