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
Copy file name to clipboardExpand all lines: articles/azure-cache-for-redis/cache-python-get-started.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,9 +39,9 @@ The following example used `pip3` for Python 3 to install `redis-py` on Windows
39
39
40
40
:::image type="content" source="media/cache-python-get-started/cache-python-install-redis-py.png" alt-text="Screenshot of a terminal showing an install of redis-py interface to Azure Cache for Redis.":::
41
41
42
-
## Create a sample Python script to access your cache
42
+
## Create a Python script to access your cache
43
43
44
-
Create a Python that uses either Microsoft Entra ID or access keys to connect to an Azure Cache for Redis. We recommend you use Microsoft Entra ID.
44
+
Create a Python script to that uses either Microsoft Entra ID or access keys to connect to an Azure Cache for Redis. We recommend you use Microsoft Entra ID.
45
45
46
46
## [Microsoft Entra ID Authentication (recommended)](#tab/entraid)
47
47
@@ -57,7 +57,7 @@ Create a Python that uses either Microsoft Entra ID or access keys to connect to
57
57
pip install azure-identity
58
58
```
59
59
60
-
### Create a sample python app
60
+
### Create a Python script using Microsoft Entra ID
61
61
62
62
1. Create a new text file, add the following script, and save the file as `PythonApplication1.py`.
63
63
@@ -110,11 +110,11 @@ Create a Python that uses either Microsoft Entra ID or access keys to connect to
110
110
111
111
:::image type="content" source="media/cache-python-get-started/cache-python-completed.png" alt-text="Screenshot of a terminal showing a Python script to test cache access.":::
112
112
113
-
## Create a sample Python script with reauthentication
113
+
### Create a Python script using reauthentication
114
114
115
115
Microsoft Entra ID access tokens have limited lifespans, [averaging 75 minutes](/entra/identity-platform/configurable-token-lifetimes#token-lifetime-policies-for-access-saml-and-id-tokens). In order to maintain a connection to your cache, you need to refresh the token. This example demonstrates how to do this using Python.
116
116
117
-
1. Create a new text file, add the following script, andsave the fileas`PythonApplication2.py`.
117
+
1. Create a new text file, add the following script. Then, save the fileas`PythonApplication2.py`.
118
118
119
119
1. Replace `<Your Host Name>`with the value from your Azure Cache for Redis instance. Your host name is of the form `<DNS name>.redis.cache.windows.net`.
120
120
@@ -195,9 +195,9 @@ Microsoft Entra ID access tokens have limited lifespans, [averaging 75 minutes](
## Read and write to the cache from the command line
198
+
### Read and write to the cache from the command line
199
199
200
-
Run [Python from the command line](https://docs.python.org/3/faq/windows.html#id2) to test your cache. First, initiate the python interpreter in your command line by typing `py`, and then use the following code. Replace `<Your Host Name>` and `<Your Access Key>` with the values from your Azure Cache for Redis instance. Your host name is of the form `<DNS name>.redis.cache.windows.net`.
200
+
Run [Python from the command line](https://docs.python.org/3/faq/windows.html#id2) to test your cache. First, initiate the Python interpreter in your command line by typing `py`, and then use the following code. Replace `<Your Host Name>` and `<Your Access Key>` with the values from your Azure Cache for Redis instance. Your host name is of the form `<DNS name>.redis.cache.windows.net`.
201
201
202
202
```python
203
203
>>>import redis
@@ -209,7 +209,7 @@ True
209
209
b'bar'
210
210
```
211
211
212
-
## Create a Python sample app
212
+
### Create a Python script using access keys
213
213
214
214
Create a new text file, add the following script, and save the fileas`PythonApplication1.py`. Replace `<Your Host Name>`and`<Your Access Key>`with the values from your Azure Cache for Redis instance. Your host name is of the form `<DNS name>.redis.cache.windows.net`.
0 commit comments