You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I updated the Redis Python quickstart by consolidating the sample into a single, clean, and fully functional script. The previous fragmented/AI-style examples (including emojis and excessive comments) were removed. I also added proper try/except/finally handling to improve reliability and updated the console output example to align with the new script. These changes improve clarity and address customer concerns regarding unusable code. Additionally, need to remove closing note indicating that the article was created with assistance from AI, as it is no longer appropriate.
📡 Connecting to: contosob116.westus3.redis.azure.net:10000
132
-
133
-
✅ Ping returned : True
134
-
135
-
✅ SET Message succeeded: True
136
-
137
-
✅ GET Message returned : Hello, The cache is working with Python!
138
-
139
-
🎉 All Redis operations completed successfully!
140
-
141
-
🔐 Redis connection closed
82
+
PING: True
83
+
GET: Hello from Azure Managed Redis!
142
84
143
85
```
144
86
145
87
Here, you can see this code sample in its entirety. The code contains some error checking omitted from the earlier code explanations for simplicity. The final step is closing the connection to the cache.
146
88
147
89
```python
148
-
# Python Quickstart using Azure Entra ID authentication
149
-
# Azure Managed Redis cache that you created using the Azure portal, or CLI
150
-
# This script demonstrates secure connection using Microsoft Entra ID authentication
151
-
# This script demonstrates secure connection using the default Azure credential provider
152
-
# You should be a user on the cache and logged in to Azure CLI with the same account using `az login`
153
-
154
90
import redis
155
91
from azure.identity import DefaultAzureCredential
156
92
from redis_entraid.cred_provider import create_from_default_azure_credential
157
93
158
-
# Connection details for your cache
159
-
# Get the connection details for the Redis instance
160
-
redis_host ="<host-url>"# Replace with your cache info
161
-
redis_port =<port number># Replace with your cache info
0 commit comments