Skip to content

Commit afd9049

Browse files
committed
Adding EntraID explainer to README
1 parent 233615b commit afd9049

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,36 @@ You can run these modules in your self-hosted Redis deployment, or you can use [
370370

371371
To learn more, read [our documentation](docs/redis_modules.md).
372372

373+
## Connecting to Azure Managed Redis with EntraID
374+
375+
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.
376+
Simply install the library with:
377+
378+
```
379+
pip install redis-entraid
380+
```
381+
382+
Then you'll initialize your credentials provider, connect to redis, and pass the database object into your metamodel:
383+
384+
```python
385+
386+
from redis import Redis
387+
from redis_entraid.cred_provider import create_from_default_azure_credential
388+
from redis_om import HashModel, Field
389+
credential_provider = create_from_default_azure_credential(
390+
("https://redis.azure.com/.default",),
391+
)
392+
393+
db = Redis(host="cluster-naem.region.redis.azure.net", port=10000, ssl=True, ssl_cert_reqs=None, credential_provider=credential_provider)
394+
db.flushdb()
395+
class User(HashModel):
396+
first_name: str
397+
last_name: str = Field(index=True)
398+
399+
class Meta:
400+
database = db
401+
```
402+
373403
## ❤️ Contributing
374404

375405
We'd love your contributions!

0 commit comments

Comments
 (0)