Aspire.Microsoft.Azure.StackExchangeRedis
13.0.0-preview.1.25560.3
Prefix Reserved
dotnet add package Aspire.Microsoft.Azure.StackExchangeRedis --version 13.0.0-preview.1.25560.3
NuGet\Install-Package Aspire.Microsoft.Azure.StackExchangeRedis -Version 13.0.0-preview.1.25560.3
<PackageReference Include="Aspire.Microsoft.Azure.StackExchangeRedis" Version="13.0.0-preview.1.25560.3" />
<PackageVersion Include="Aspire.Microsoft.Azure.StackExchangeRedis" Version="13.0.0-preview.1.25560.3" />
<PackageReference Include="Aspire.Microsoft.Azure.StackExchangeRedis" />
paket add Aspire.Microsoft.Azure.StackExchangeRedis --version 13.0.0-preview.1.25560.3
#r "nuget: Aspire.Microsoft.Azure.StackExchangeRedis, 13.0.0-preview.1.25560.3"
#:package Aspire.Microsoft.Azure.StackExchangeRedis@13.0.0-preview.1.25560.3
#addin nuget:?package=Aspire.Microsoft.Azure.StackExchangeRedis&version=13.0.0-preview.1.25560.3&prerelease
#tool nuget:?package=Aspire.Microsoft.Azure.StackExchangeRedis&version=13.0.0-preview.1.25560.3&prerelease
Aspire.Microsoft.Azure.StackExchangeRedis library
Configures the Aspire.StackExchange.Redis package with Azure AD authentication when connecting to an Azure Cache for Redis instance.
Getting started
Prerequisites
- Azure Cache for Redis instance, learn more about how to Create an Azure Cache for Redis resource or Use the Aspire Azure Redis hosting integration.
Differences with Aspire.StackExchange.Redis
The Aspire.Microsoft.Azure.StackExchangeRedis library is a wrapper around the Aspire.StackExchange.Redis library that provides additional features for connecting to Azure Cache for Redis with Azure AD authentication. If you don't need these features, you can use the Aspire.StackExchange.Redis library instead.
At runtime the client integration will use Azure AD authentication when a credential is configured, allowing passwordless authentication with Azure Cache for Redis.
Install the package
Install the Aspire Azure StackExchange.Redis library with NuGet:
dotnet add package Aspire.Microsoft.Azure.StackExchangeRedis
Usage example
In the Program.cs file of your project, use the AddRedisClientBuilder extension method with WithAzureAuthentication to register a IConnectionMultiplexer for use via the dependency injection container. The method takes a connection name parameter.
builder.AddRedisClientBuilder("cache")
.WithAzureAuthentication();
You can then retrieve the IConnectionMultiplexer instance using dependency injection. For example, to retrieve the connection from a Web API controller:
private readonly IConnectionMultiplexer _cache;
public ProductsController(IConnectionMultiplexer cache)
{
_cache = cache;
}
Using keyed services
You can also register keyed Redis clients using the keyed services pattern:
builder.AddKeyedRedisClientBuilder("cache")
.WithAzureAuthentication();
Then retrieve the keyed service:
public ProductsController([FromKeyedServices("cache")] IConnectionMultiplexer cache)
{
_cache = cache;
}
Adding distributed caching and output caching
You can add distributed caching and output caching to the Redis client by chaining additional methods:
builder.AddRedisClientBuilder("cache")
.WithAzureAuthentication()
.WithDistributedCache()
.WithOutputCache();
Configure Azure AD authentication
Use the WithAzureAuthentication method to establish a connection using Azure AD authentication. If no credential is provided, the DefaultAzureCredential is used.
builder.AddRedisClientBuilder("cache")
.WithAzureAuthentication(new ManagedIdentityCredential());
AppHost extensions
In your AppHost project, install the Aspire.Hosting.Azure.Redis library with NuGet:
dotnet add package Aspire.Hosting.Azure.Redis
Then, in the Program.cs file of AppHost, register an Azure Cache for Redis instance and consume the connection using the following methods:
var redis = builder.AddAzureRedis("cache");
var myService = builder.AddProject<Projects.MyService>()
.WithReference(redis);
The WithReference method configures a connection in the MyService project named cache. In the Program.cs file of MyService, the Redis connection can be consumed using:
builder.AddRedisClientBuilder("cache")
.WithAzureAuthentication();
This will also require your Azure environment to be configured by following these instructions.
Additional documentation
- https://stackexchange.github.io/StackExchange.Redis/
- https://github.com/Azure/Microsoft.Azure.StackExchangeRedis
Feedback & contributing
https://github.com/dotnet/aspire
*Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Aspire.StackExchange.Redis (>= 13.0.0)
- AspNetCore.HealthChecks.Redis (>= 9.0.0)
- Azure.Core (>= 1.49.0)
- Azure.Identity (>= 1.17.0)
- Microsoft.Azure.StackExchangeRedis (>= 3.2.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.AutoActivation (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Primitives (>= 10.0.0)
- OpenTelemetry.Extensions.Hosting (>= 1.9.0)
- StackExchange.Redis (>= 2.9.32)
-
net8.0
- Aspire.StackExchange.Redis (>= 13.0.0)
- AspNetCore.HealthChecks.Redis (>= 9.0.0)
- Azure.Core (>= 1.49.0)
- Azure.Identity (>= 1.17.0)
- Microsoft.Azure.StackExchangeRedis (>= 3.2.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection.AutoActivation (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.22)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Primitives (>= 8.0.0)
- OpenTelemetry.Extensions.Hosting (>= 1.9.0)
- StackExchange.Redis (>= 2.9.32)
-
net9.0
- Aspire.StackExchange.Redis (>= 13.0.0)
- AspNetCore.HealthChecks.Redis (>= 9.0.0)
- Azure.Core (>= 1.49.0)
- Azure.Identity (>= 1.17.0)
- Microsoft.Azure.StackExchangeRedis (>= 3.2.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.11)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.11)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.11)
- Microsoft.Extensions.DependencyInjection.AutoActivation (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.11)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.11)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.11)
- Microsoft.Extensions.Options (>= 9.0.11)
- Microsoft.Extensions.Primitives (>= 9.0.11)
- OpenTelemetry.Extensions.Hosting (>= 1.9.0)
- StackExchange.Redis (>= 2.9.32)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 13.0.0-preview.1.25560.3 | 44 | 11/11/2025 |
| 9.5.2-preview.1.25522.3 | 685 | 10/23/2025 |
| 9.5.1-preview.1.25502.11 | 2,103 | 10/3/2025 |
| 9.5.0-preview.1.25474.7 | 337 | 9/25/2025 |