Aspire.Microsoft.Azure.StackExchangeRedis 13.0.0-preview.1.25560.3

Prefix Reserved
This is a prerelease version of Aspire.Microsoft.Azure.StackExchangeRedis.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aspire.Microsoft.Azure.StackExchangeRedis" Version="13.0.0-preview.1.25560.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aspire.Microsoft.Azure.StackExchangeRedis" Version="13.0.0-preview.1.25560.3" />
                    
Directory.Packages.props
<PackageReference Include="Aspire.Microsoft.Azure.StackExchangeRedis" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
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"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Aspire.Microsoft.Azure.StackExchangeRedis@13.0.0-preview.1.25560.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Aspire.Microsoft.Azure.StackExchangeRedis&version=13.0.0-preview.1.25560.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Aspire.Microsoft.Azure.StackExchangeRedis&version=13.0.0-preview.1.25560.3&prerelease
                    
Install as a Cake Tool

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

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

Feedback & contributing

https://github.com/dotnet/aspire

*Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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