Skip to content

Commit 725f538

Browse files
committed
acrolinx fixes
1 parent 343c867 commit 725f538

3 files changed

Lines changed: 79 additions & 74 deletions

File tree

articles/redis/aspnet.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
---
22
title: Create an ASP.NET web app with an Azure Managed Redis cache
3-
description: In this quickstart, you learn how to create an ASP.NET Core web app with an Azure Redis cache.
3+
description: In this quickstart, you learn how to create an ASP.NET Core web app with an Azure Managed Redis cache.
44
ms.date: 01/30/2026
55
ms.topic: quickstart
66
ms.devlang: csharp
77
zone_pivot_groups: redis-type
88
appliesto:
9-
- ✅ Azure Cache for Redis
10-
# Customer intent: As an ASP.NET developer, new to Azure Redis, I want to create a new Node.js app that uses Azure Managed Redis or Azure Cache for Redis.
9+
- ✅ Azure Managed Redis
10+
# Customer intent: As an ASP.NET developer, new to Azure Managed Redis, I want to create a new .NET app that uses Azure Managed Redis.
1111
---
1212

1313
# Azure Managed Redis sample - ASP.NET Core Web API
1414

1515
This sample shows how to connect an ASP.NET Core Web API to Azure Managed Redis by using Microsoft Entra ID authentication with the `DefaultAzureCredential` flow. The application avoids traditional connection string-based authentication in favor of token-based, Microsoft Entra ID access, which aligns with modern security best practices.
1616

17-
## Overview
18-
1917
The application is a minimal ASP.NET Core 8.0 Web API that:
2018

2119
1. Establishes a secure, authenticated connection to Azure Managed Redis at startup.
2220
1. Exposes a simple REST endpoint that reads and writes data to the cache.
2321
1. Demonstrates proper Redis connection lifecycle management by using dependency injection.
2422

23+
## Skip to the code on GitHub
24+
25+
Clone the [Microsoft.Azure.StackExchangeRedis](https://github.com/Azure/Microsoft.Azure.StackExchangeRedis/tree/main/sample.aspnet) repo on GitHub.
26+
2527
## Prerequisites
2628

2729
- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
2830
- An **Azure Managed Redis** instance provisioned in your Azure subscription
29-
- Your Azure user or service principal must have the appropriate **Data Access Policy** assigned on the Redis resource, such as `Data Owner`, `Data Contributor`, or a custom policy with read and write permissions
31+
- Your Azure user or service principal must be added as a Redis user on the cache. In the Azure portal, go to **Authentication** on the Resource menu, select **User or service principal**, and add your identity.
3032
- [Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli) for local development authentication
3133

3234
## Required NuGet Packages
@@ -77,9 +79,9 @@ The `DefaultAzureCredential` automatically picks up your Azure CLI credentials a
7779

7880
In Azure-hosted environments such as App Service, Container Apps, and AKS, `DefaultAzureCredential` uses:
7981

80-
- **Managed Identity** (system-assigned or user-assigned)
81-
- **Workload Identity** (for Kubernetes scenarios)
82-
- **Environment variables** (for service principal authentication)
82+
- **Managed Identity** - system-assigned or user-assigned
83+
- **Workload Identity** - for Kubernetes scenarios
84+
- **Environment variables** - for service principal authentication
8385

8486
You don't need to change your code. The same `DefaultAzureCredential` seamlessly adapts to the environment.
8587

@@ -186,12 +188,10 @@ info: Microsoft.Azure.StackExchangeRedis.Sample.AspNet.Controllers.SampleControl
186188
| Issue | Resolution |
187189
| ------- | ------------ |
188190
| `No connection is available` | Verify the endpoint format and port (`10000`). Make sure the Redis instance is provisioned and accessible. |
189-
| `AuthenticationFailedException` | Run `az login` to refresh credentials. Verify your identity has the required Data Access Policy on the Redis resource. |
190-
| `Unauthorized` | Ensure your Microsoft Entra ID identity is assigned to a data access role on the Azure Managed Redis instance. |
191+
| `AuthenticationFailedException` | Run `az login` to refresh credentials. Verify your identity is added as a Redis user under **Authentication** on the Resource menu. |
192+
| `Unauthorized` | Ensure your Microsoft Entra ID identity is added as a Redis user on the Azure Managed Redis instance. For more information, see [Use Microsoft Entra ID for cache authentication](entra-for-authentication.md). |
191193

192194
## Related content
193195

194-
- [Azure Managed Redis documentation](https://learn.microsoft.com/azure/azure-cache-for-redis/)
195-
- [Microsoft Entra ID authentication for Azure Cache for Redis](https://learn.microsoft.com/azure/azure-cache-for-redis/cache-azure-active-directory-for-authentication)
196+
- [Microsoft Entra ID authentication for Azure Managed Redis](entra-for-authentication.md)
196197
- [DefaultAzureCredential overview](https://learn.microsoft.com/dotnet/azure/sdk/authentication#defaultazurecredential)
197-
- [StackExchange.Redis documentation](https://stackexchange.github.io/StackExchange.Redis/)

articles/redis/dotnet.md

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,62 @@ description: In this quickstart, learn how to use Azure Managed Redis in a .NET
44
ms.date: 01/30/2026
55
ms.topic: quickstart
66
ms.devlang: csharp
7-
zone_pivot_groups: redis-type
87
appliesto:
98
- ✅ Azure Managed Redis
109
# Customer intent: As a .NET developer, new to Azure Managed Redis, I want to create a new dotnet app that uses Azure Managed Redis.
1110
---
1211

13-
# Quickstart: Use Azure Redis in .NET Core
12+
# Quickstart: Use Azure Managed Redis in .NET Core
1413

15-
This is a .NET 8 console application that demonstrates how to connect to **Azure Managed Redis** using **Microsoft Entra ID** authentication. The core value proposition is **passwordless authentication** with automatic token refresh, providing a secure and modern approach to Redis connectivity.
14+
This .NET 8 console application demonstrates how to connect to **Azure Managed Redis** by using **Microsoft Entra ID** authentication. The core value proposition is **passwordless authentication** with automatic token refresh, providing a secure and modern approach to Redis connectivity.
1615

1716
## Skip to the code on GitHub
1817

19-
Clone the repo [Microsoft.Azure.StackExchangeRedis](https://github.com/Azure/Microsoft.Azure.StackExchangeRedis/tree/main/sample) on GitHub.
18+
Clone the [Microsoft.Azure.StackExchangeRedis](https://github.com/Azure/Microsoft.Azure.StackExchangeRedis/tree/main/sample) repo on GitHub.
19+
20+
## Prerequisites
21+
22+
- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
23+
- An **Azure Managed Redis** instance provisioned in your Azure subscription
24+
- Your Azure user or service principal must be added as a Redis user on the cache. In the Azure portal, go to **Authentication** on the Resource menu, select **User or service principal**, and add your identity.
25+
- [Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli) for local development authentication
2026

2127
## Required NuGet Packages
2228

23-
| Package | Purpose |
24-
|||
25-
| `Microsoft.Azure.StackExchangeRedis` | Extension library that adds Entra ID authentication to StackExchange.Redis |
26-
| `Azure.Identity` | Provides `DefaultAzureCredential` and other Azure identity implementations |
27-
| `StackExchange.Redis` | The underlying Redis client (pulled in as a dependency) |
28-
| `Microsoft.Extensions.Logging.Console` | Console logging for diagnostics |
29+
| Package | Purpose |
30+
|----------------------------------------|--------------------------------------------------------------------------------------|
31+
| `Microsoft.Azure.StackExchangeRedis` | Extension library that adds Microsoft Entra ID authentication to StackExchange.Redis |
32+
| `Azure.Identity` | Provides `DefaultAzureCredential` and other Azure identity implementations |
33+
| `StackExchange.Redis` | The underlying Redis client (pulled in as a dependency) |
34+
| `Microsoft.Extensions.Logging.Console` | Console logging for diagnostics |
2935

30-
## Authentication Methods
36+
## Authentication methods
3137

3238
The extension supports multiple identity types, each with a corresponding `ConfigureForAzure*()` extension method:
3339

34-
1. **`DefaultAzureCredential`** The recommended approach. It chains multiple credential sources (environment variables, managed identity, Azure CLI login, Visual Studio credentials, etc.) and uses the first one that works. Ideal for code that runs both locally and in Azure.
40+
1. **`DefaultAzureCredential`** - The recommended approach. It chains multiple credential sources (environment variables, managed identity, Azure CLI authentication, Visual Studio credentials, and more) and uses the first one that works. It's ideal for code that runs both locally and in Azure.
3541

36-
2. **User-Assigned Managed Identity** For Azure-hosted apps where you explicitly specify which managed identity to use via its client ID.
42+
1. **User-Assigned Managed Identity** - For Azure-hosted apps where you explicitly specify which managed identity to use by providing its client ID.
3743

38-
3. **System-Assigned Managed Identity** For Azure-hosted apps using the identity automatically assigned to the resource.
44+
1. **System-Assigned Managed Identity** - For Azure-hosted apps that use the identity automatically assigned to the resource.
3945

40-
4. **Service Principal (Secret)** Client ID + Tenant ID + secret for automated/CI scenarios.
46+
1. **Service Principal (Secret)** - Client ID, tenant ID, and secret for automated or CI scenarios.
4147

42-
5. **Service Principal (Certificate)** Client ID + Tenant ID + X.509 certificate for higher security.
48+
1. **Service Principal (Certificate)** - Client ID, tenant ID, and X.509 certificate for higher security.
4349

44-
### How `DefaultAzureCredential` Works Locally
50+
### How `DefaultAzureCredential` works locally
4551

46-
When developing locally, `DefaultAzureCredential` will attempt to authenticate using:
52+
When you develop locally, `DefaultAzureCredential` attempts to authenticate by using the following methods:
4753

4854
```bash
4955
az login
5056
```
5157

52-
This signs you into the Azure CLI with your Microsoft Entra ID account. The SDK detects your cached credentials and uses them to obtain tokens. Your Entra ID user must be configured as a **Redis User** on the Azure Managed Redis resource via the **Data Access Configuration** blade in the Azure portal.
58+
This method signs you in to the Azure CLI by using your Microsoft Entra ID account. The SDK detects your cached credentials and uses them to obtain tokens. You must configure your Microsoft Entra ID user as a **Redis User** on the Azure Managed Redis resource through the **Authentication** on the Resource menu in the Azure portal.
5359

54-
## Key Implementation Patterns
60+
## Key implementation patterns
5561

56-
**Connection Configuration:**
62+
**Connection configuration:**
5763

5864
```csharp
5965
ConfigurationOptions configurationOptions = new()
@@ -65,39 +71,39 @@ ConfigurationOptions configurationOptions = new()
6571
};
6672
```
6773

68-
**Entra ID Setup:**
74+
**Entra ID setup:**
6975

7076
```csharp
7177
await configurationOptions.ConfigureForAzureWithTokenCredentialAsync(new DefaultAzureCredential());
7278
var connection = await ConnectionMultiplexer.ConnectAsync(configurationOptions);
7379
```
7480

75-
**Basic Redis Operations:**
81+
**Basic Redis operations:**
7682

7783
```csharp
7884
var database = connection.GetDatabase();
7985
await database.StringSetAsync("key", "value");
8086
var value = await database.StringGetAsync("key");
8187
```
8288

83-
## Token Lifecycle & Automatic Re-authentication
89+
## Token lifecycle and automatic re-authentication
8490

85-
The extension handles the OAuth2 token lifecycle automatically:
91+
The extension automatically handles the OAuth2 token lifecycle:
8692

87-
1. **Initial acquisition** — A token is obtained before connecting.
88-
2. **Proactive refresh** Before the token expires (~1 hour), a fresh token is acquired in the background.
89-
3. **Re-authentication** — The connection is re-authenticated with the new token without dropping commands.
93+
1. **Initial acquisition** - It gets a token before connecting.
94+
1. **Proactive refresh** - Before the token expires (about one hour), it gets a fresh token in the background.
95+
1. **Re-authentication** - It re-authenticates the connection with the new token without dropping commands.
9096

91-
You can subscribe to token events for observability:
97+
For observability, you can subscribe to token events:
9298

93-
| Event | Purpose |
94-
|-||
95-
| `TokenRefreshed` | New token acquired |
96-
| `TokenRefreshFailed` | Token refresh failed (still using old token) |
97-
| `ConnectionReauthenticated` | Connection successfully re-authenticated |
98-
| `ConnectionReauthenticationFailed` | Re-auth failed for a connection |
99+
| Event | Purpose |
100+
|------------------------------------|----------------------------------------------|
101+
| `TokenRefreshed` | New token acquired |
102+
| `TokenRefreshFailed` | Token refresh failed (still using old token) |
103+
| `ConnectionReauthenticated` | Connection successfully re-authenticated |
104+
| `ConnectionReauthenticationFailed` | Re-auth failed for a connection |
99105

100-
## RESP3 vs RESP2 Protocol
106+
## RESP3 vs. RESP2 protocol
101107

102108
The sample uses **RESP3** (`Protocol = RedisProtocol.Resp3`) because:
103109

@@ -106,39 +112,38 @@ The sample uses **RESP3** (`Protocol = RedisProtocol.Resp3`) because:
106112
- Pub/sub connections close when their token expires, causing brief interruptions.
107113
- RESP3 multiplexes everything on one connection, avoiding these disruptions.
108114

109-
## Azure Prerequisites
115+
## Azure prerequisites
110116

111-
1. **Create an Azure Managed Redis** instance.
112-
2. **Enable Microsoft Entra ID authentication** under "Data Access Configuration."
113-
3. **Add your identity as a Redis User** with the appropriate permissions (Data Owner, Data Contributor, etc.).
114-
4. **Run `az login`** locally to authenticate with your Entra ID account.
117+
1. Create an Azure Managed Redis instance.
118+
1. Enable Microsoft Entra ID authentication under "Data Access Configuration."
119+
1. Add your identity as a Redis User with the appropriate permissions (Data Owner, Data Contributor, and so on).
120+
1. **Run `az login`** locally to authenticate with your Entra ID account.
115121

116-
## Redis Basics Refresher
122+
## Basic Redis concepts
117123

118-
| Concept | Description |
119-
||-|
120-
| `ConnectionMultiplexer` | Singleton, thread-safe connection pool to Redis—create once, reuse for the app lifetime. |
121-
| `IDatabase` | Interface for executing commands (`StringGet`, `StringSet`, `HashGet`, etc.). |
122-
| Endpoint format | `endpoint:10000` (TLS) for Azure Managed Redis. |
123-
| Commands | Redis is single-threaded per key—atomic operations like `INCR`, `SETNX` avoid race conditions. |
124+
| Concept | Description |
125+
|-------------------------|----------------------------------------------------------------------------------------------------|
126+
| `ConnectionMultiplexer` | Singleton, thread-safe connection pool to Redis. Create it once and reuse it for the app lifetime. |
127+
| `IDatabase` | Interface for executing commands (`StringGet`, `StringSet`, `HashGet`, and so on). |
128+
| Endpoint format | `endpoint:10000` (TLS) for Azure Managed Redis. |
124129

125-
## Running the Sample
130+
## Running the sample
126131

127132
```powershell
128133
az login
129134
cd sample
130135
dotnet run
131136
```
132137

133-
Enter your Redis endpoint (e.g., <myredis.redis.azure.net:1000>), choose authentication method **1** (DefaultAzureCredential), and watch the `+` characters print every second as commands succeed. Let it run for 60+ minutes to verify automatic token refresh works.
138+
Enter your Redis endpoint (for example, `<myredis.redis.azure.net:1000>`), choose authentication method **1** (DefaultAzureCredential), and watch the `+` characters print every second as commands succeed. Let it run for more than 60 minutes to verify automatic token refresh works.
134139

135-
## Production Considerations
140+
## Production considerations
136141

137-
| Setting | Sample Value | Production Value |
138-
||--||
139-
| `AbortOnConnectFail` | `true` | `false` (retry on startup) |
140-
| `BacklogPolicy` | `FailFast` | `Default` (queue commands during transient failures) |
141-
| Connection lifetime | Demo loop | Singleton via DI (`IConnectionMultiplexer`) |
142+
| Setting | Sample value | Production value |
143+
|----------------------|--------------|------------------------------------------------------|
144+
| `AbortOnConnectFail` | `true` | `false` (retry on startup) |
145+
| `BacklogPolicy` | `FailFast` | `Default` (queue commands during transient failures) |
146+
| Connection lifetime | Demo loop | Singleton via DI (`IConnectionMultiplexer`) |
142147

143148
This sample provides a complete reference implementation for secure, passwordless Entra ID authentication in any .NET application that uses Azure Managed Redis.
144149

articles/redis/entra-for-authentication.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ If you have used access keys in the past for authentication, you need to update
4646

4747
### Microsoft Entra client workflow
4848

49-
1. Configure your client application to acquire a Microsoft Entra token for scope, `https://redis.azure.com/.default`, or `acca5fbb-b7e4-4009-81f1-37e38fd66d78/.default`, by using the [Microsoft Authentication Library (MSAL)](/azure/active-directory/develop/msal-overview).
49+
1. Configure your client application to acquire a Microsoft Entra token for scope, `https://redis.azure.com/.default`, or `acca5fbb-b7e4-4009-81f1-37e38fd66d78/.default`, by using the [Microsoft Authentication Library (MSAL)](/azure/active-directory/develop/msal-overview).
5050

5151
1. Update your Redis connection logic to use the following `User` and `Password`:
5252

@@ -106,13 +106,13 @@ To disable access keys, follow this procedure:
106106

107107
1. In the Azure portal, select the Azure Managed Redis instance where you want to disable access keys.
108108

109-
1. On the **Resource** menu, select**Authentication**.
109+
1. On the **Resource** menu, select **Authentication**.
110110

111-
1. On the working pane, select**Access keys**.
111+
1. On the working pane, select **Access keys**.
112112

113113
1. Select the **Access Keys Authentication** control to disable access keys.
114114

115-
1. Confirm that you want to update your configuration by selecting**Yes**.
115+
1. Confirm that you want to update your configuration by selecting **Yes**.
116116

117117
> [!IMPORTANT]
118118
> When the **Access Keys Authentication** setting is changed for a cache, all existing client connections, using access keys or Microsoft Entra, are terminated. Follow the best practices to implement proper retry mechanisms for reconnecting Microsoft Entra-based connections. For more information, see [Connection resilience](best-practices-connection.md).

0 commit comments

Comments
 (0)