共用方式為


AzureRedisExtensions.WithAccessKeyAuthentication Method

Definition

Configures the resource to use access key authentication for Azure Cache for Redis.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureRedisCacheResource> WithAccessKeyAuthentication (this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureRedisCacheResource> builder);
static member WithAccessKeyAuthentication : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureRedisCacheResource> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureRedisCacheResource>
<Extension()>
Public Function WithAccessKeyAuthentication (builder As IResourceBuilder(Of AzureRedisCacheResource)) As IResourceBuilder(Of AzureRedisCacheResource)

Parameters

builder
IResourceBuilder<AzureRedisCacheResource>

The Azure Cache for Redis resource builder.

Returns

A reference to the IResourceBuilder<T> builder.

Examples

The following example creates an Azure Cache for Redis resource that uses access key authentication.

var builder = DistributedApplication.CreateBuilder(args);

var cache = builder.AddAzureRedis("cache")
    .WithAccessKeyAuthentication();

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

builder.Build().Run();

Applies to