Skip to content

Commit a599a4e

Browse files
committed
added include file
1 parent efe3efa commit a599a4e

File tree

4 files changed

+46
-15
lines changed

4 files changed

+46
-15
lines changed

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ description: In this quickstart, you learn how to create a Python App that uses
44
author: flang-msft
55

66
ms.author: franlanglois
7-
8-
ms.date: 02/15/2023
7+
ms.date: 07/03/2024
98
ms.topic: quickstart
109
ms.service: cache
1110
ms.devlang: python
1211
ms.custom: mvc, devx-track-python, mode-api, py-fresh-zinc
12+
1313
---
14+
1415
# Quickstart: Use Azure Cache for Redis in Python
1516

1617
In this article, you incorporate Azure Cache for Redis into a Python app to have access to a secure, dedicated cache that is accessible from any application within Azure.
@@ -39,18 +40,25 @@ The following example used `pip3` for Python 3 to install `redis-py` on Windows
3940

4041
## [Microsoft EntraID Authentication (recommended)](#tab/entraid)
4142

42-
## Enable Microsoft EntraID and add a User or Service Principal
43-
<--Fran, we probably need an include file on enabling EntraID-->
44-
Blah blah blah, do the steps listed [here](cache-azure-active-directory-for-authentication)
43+
[!INCLUDE [cache-entra-access](includes/cache-entra-access.md)]
44+
45+
<!-- ## Enable Microsoft EntraID and add a User or Service Principal -->
46+
<!--
47+
Fran, we probably need an include file on enabling EntraID
48+
Blah blah blah, do the steps listed [here](cache-azure-active-directory-for-authentication)
49+
-->
4550

4651
## Install the Microsoft Authentication Library
47-
The [Microsoft Authentication Library (MSAL)](../../entra/identity-platform/msal-overview) allows you to acquire security tokens from Microsoft identity to authenticate users. There's a [Python Azure identity client library](../../python/api/overview/azure/identity-readme) available that uses MSAL to provide token authentication support. Install this library using `pip`:
52+
The [Microsoft Authentication Library (MSAL)](../../entra/identity-platform/msal-overview) allows you to acquire security tokens from Microsoft identity to authenticate users.
53+
54+
There's a [Python Azure identity client library](../../python/api/overview/azure/identity-readme) available that uses MSAL to provide token authentication support. Install this library using `pip`:
4855

4956
```python
5057
pip install azure-identity
5158
```
5259

5360
## Create a sample python app
61+
5462
Create a new text file, add the following script, and save the file as `PythonApplication1.py`. 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`. Replace `<Your Username>` with the values from your Microsoft EntraID user.
5563

5664
```python
@@ -95,7 +103,8 @@ Run `PythonApplication1.py` with Python. You should see results like the followi
95103
:::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.":::
96104

97105
## Create a sample python app with reauthentication
98-
Microsoft EntraID 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.
106+
107+
Microsoft EntraID access tokens have limited lifespans, [averaging 75 minutes](/azure/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.
99108

100109
Create a new text file, add the following script, and save the file as `PythonApplication2.py`. 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`. Replace `<Your Username>` with the values from your Microsoft EntraID user.
101110

@@ -171,11 +180,11 @@ Run `PythonApplication2.py` with Python. You should see results like the followi
171180
Unlike the first example, If your token expires, this example automatically refreshes it.
172181

173182
## [Access Key Authentication](#tab/accesskey)
183+
174184
[!INCLUDE [redis-cache-create](includes/redis-cache-access-keys.md)]
175185

176186
## Read and write to the cache from the command line
177187

178-
179188
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`.
180189

181190
```python
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
ms.service: cache
3+
ms.topic: include
4+
ms.date: 07/03/2024
5+
ms.author: franlanglois
6+
author: flang-msft
7+
---
8+
9+
### Enable Microsoft Entra ID authentication on your cache
10+
11+
1. In the Azure portal, select the Azure Cache for Redis instance where you'd like to configure Microsoft Entra token-based authentication.
12+
13+
1. Select **Authentication** from the Resource menu.
14+
15+
1. In the working pane, select **Enable Microsoft Entra Authentication**.
16+
17+
1. Select **Enable Microsoft Entra Authentication**, and enter the name of a valid user. The user you enter is automatically assigned _Data Owner Access Policy_ by default when you select **Save**. You can also enter a managed identity or service principal to connect to your cache instance.
18+
19+
:::image type="content" source="media/cache-entra-access/cache-enable-microsoft-entra.png" alt-text="Screenshot showing authentication selected in the resource menu and the enable Microsoft Entra authentication checked.":::
20+
21+
1. A popup dialog box displays asking if you want to update your configuration, and informing you that it takes several minutes. Select **Yes.**
22+
23+
> [!IMPORTANT]
24+
> Once the enable operation is complete, the nodes in your cache instance reboots to load the new configuration. We recommend performing this operation during your maintenance window or outside your peak business hours. The operation can take up to 30 minutes.
25+
26+
For information on using Microsoft Entra ID with Azure CLI, see the [references pages for identity](/cli/azure/redis/identity).
172 KB
Loading

articles/azure-cache-for-redis/includes/redis-cache-access-keys.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
---
2-
title: "include file"
3-
description: "include file"
4-
services: cache
5-
author: flang-msft
62
ms.service: cache
7-
ms.topic: "include"
8-
ms.date: 04/25/2024
3+
ms.topic: include
4+
ms.date: 07/03/2024
95
ms.author: franlanglois
10-
ms.custom: "include file"
6+
author: flang-msft
117
---
128

139
### Retrieve host name, ports, and access keys from the Azure portal

0 commit comments

Comments
 (0)