AzureRedisEnterpriseExtensions.AddAzureRedisEnterprise Method

Definition

Adds an Azure Managed Redis resource to the application model.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureRedisEnterpriseResource> AddAzureRedisEnterprise(this Aspire.Hosting.IDistributedApplicationBuilder builder, string name);
static member AddAzureRedisEnterprise : Aspire.Hosting.IDistributedApplicationBuilder * string -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureRedisEnterpriseResource>
<Extension()>
Public Function AddAzureRedisEnterprise (builder As IDistributedApplicationBuilder, name As String) As IResourceBuilder(Of AzureRedisEnterpriseResource)

Parameters

builder
IDistributedApplicationBuilder

The builder for the distributed application.

name
String

The name of the resource.

Returns

A reference to the IResourceBuilder<T> builder.

Remarks

By default, the Azure Managed Redis resource is configured to use Microsoft Entra ID (Azure Active Directory) for authentication. This requires changes to the application code to use an azure credential to authenticate with the resource. See https://github.com/Azure/Microsoft.Azure.StackExchangeRedis for more information.

The following example creates an Azure Managed Redis resource and referencing that resource in a .NET project.
var builder = DistributedApplication.CreateBuilder(args);

var cache = builder.AddAzureRedisEnterprise("cache");

builder.AddProject<Projects.ProductService>()
    .WithReference(cache);

builder.Build().Run();

Applies to