Skip to content

Commit d1b1e1b

Browse files
authored
Merge pull request #221333 from flang-msft/fxl----Freshness]-Python-azure-cache-for-redis/cache-python-get-started
fxl---Updated for freshness pass
2 parents a306ea8 + 4741cae commit d1b1e1b

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

articles/azure-cache-for-redis/cache-python-get-started.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
title: 'Quickstart: Use Azure Cache for Redis in Python'
33
description: In this quickstart, you learn how to create a Python App that uses Azure Cache for Redis.
44
author: flang-msft
5+
56
ms.author: franlanglois
6-
ms.date: 11/05/2019
7+
8+
ms.date: 02/15/2023
79
ms.topic: quickstart
810
ms.service: cache
911
ms.devlang: python
1012
ms.custom: mvc, seo-python-october2019, devx-track-python, mode-api, py-fresh-zinc
11-
#Customer intent: As a Python developer new to Azure Cache for Redis, I want to create a new Python app that uses Azure Cache for Redis.
13+
1214
---
1315
# Quickstart: Use Azure Cache for Redis in Python
1416

@@ -21,7 +23,9 @@ If you want to skip straight to the code, see the [Python quickstart](https://gi
2123
## Prerequisites
2224

2325
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
24-
- [Python 2 or 3](https://www.python.org/downloads/)
26+
- Python 3
27+
- For macOS or Linux, download from [python.org](https://www.python.org/downloads/).
28+
- For Windows 11, use the [Windows Store](https://www.microsoft.com/en-us/p/python-3/9nblggh083nz?activetab=pivot:overviewtab).
2529

2630
## Create an Azure Cache for Redis instance
2731
[!INCLUDE [redis-cache-create](includes/redis-cache-create.md)]
@@ -30,15 +34,15 @@ If you want to skip straight to the code, see the [Python quickstart](https://gi
3034

3135
## Install redis-py
3236

33-
[Redis-py](https://github.com/andymccurdy/redis-py) is a Python interface to Azure Cache for Redis. Use the Python packages tool, *pip*, to install the *redis-py* package from a command prompt.
37+
[Redis-py](https://pypi.org/project/redis/) is a Python interface to Azure Cache for Redis. Use the Python packages tool, `pip`, to install the `redis-py` package from a command prompt.
3438

35-
The following example used *pip3* for Python 3 to install *redis-py* on Windows 10 from an Administrator command prompt.
39+
The following example used `pip3` for Python 3 to install `redis-py` on Windows 11 from an Administrator command prompt.
3640

37-
![Install the redis-py Python interface to Azure Cache for Redis](./media/cache-python-get-started/cache-python-install-redis-py.png)
41+
:::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.":::
3842

3943
## Read and write to the cache
4044

41-
Run Python from the command line and test your cache by using 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*.
45+
Run Python from the command line and test your cache by using 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`.
4246

4347
```python
4448
>>> import redis
@@ -51,11 +55,11 @@ b'bar'
5155
```
5256

5357
> [!IMPORTANT]
54-
> For Azure Cache for Redis version 3.0 or higher, TLS/SSL certificate check is enforced. ssl_ca_certs must be explicitly set when connecting to Azure Cache for Redis. For RedHat Linux, ssl_ca_certs are in the */etc/pki/tls/certs/ca-bundle.crt* certificate module.
58+
> For Azure Cache for Redis version 3.0 or higher, TLS/SSL certificate check is enforced. `ssl_ca_certs` must be explicitly set when connecting to Azure Cache for Redis. For RedHat Linux, `ssl_ca_certs` are in the `/etc/pki/tls/certs/ca-bundle.crt` certificate module.
5559
5660
## Create a Python sample app
5761

58-
Create a new text file, add the following script, and save the file as *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*.
62+
Create a new text file, add the following script, and save the file as `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`.
5963

6064
```python
6165
import redis
@@ -78,12 +82,12 @@ print("GET Message returned : " + result.decode("utf-8"))
7882
result = r.client_list()
7983
print("CLIENT LIST returned : ")
8084
for c in result:
81-
print("id : " + c['id'] + ", addr : " + c['addr'])
85+
print(f"id : {c['id']}, addr : {c['addr']}")
8286
```
8387

84-
Run *PythonApplication1.py* with Python. You should see results like the following example:
88+
Run `PythonApplication1.py` with Python. You should see results like the following example:
8589

86-
![Run Python script to test cache access](./media/cache-python-get-started/cache-python-completed.png)
90+
:::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.":::
8791

8892
## Clean up resources
8993

@@ -95,13 +99,15 @@ If you're finished with the Azure resource group and resources you created in th
9599
To delete the resource group and its Redis Cache for Azure instance:
96100

97101
1. From the [Azure portal](https://portal.azure.com), search for and select **Resource groups**.
102+
98103
1. In the **Filter by name** text box, enter the name of the resource group that contains your cache instance, and then select it from the search results.
104+
99105
1. On your resource group page, select **Delete resource group**.
106+
100107
1. Type the resource group name, and then select **Delete**.
101108

102-
![Delete your resource group for Azure Cache for Redis](./media/cache-python-get-started/delete-your-resource-group-for-azure-cache-for-redis.png)
109+
:::image type="content" source="./media/cache-python-get-started/delete-your-resource-group-for-azure-cache-for-redis.png" alt-text="Screenshot of the Azure portal showing how to delete the resource group for Azure Cache for Redis.":::
103110

104111
## Next steps
105112

106-
> [!div class="nextstepaction"]
107-
> [Create a simple ASP.NET web app that uses an Azure Cache for Redis.](./cache-web-app-howto.md)
113+
- [Create a simple ASP.NET web app that uses an Azure Cache for Redis.](./cache-web-app-howto.md)
2.76 KB
Loading
10.6 KB
Loading

0 commit comments

Comments
 (0)