AspireKeyVaultExtensions.AddKeyedAzureKeyVaultClient Method

Definition

Registers SecretClient as a singleton for given name in the services provided by the builder. Enables retries, corresponding health check, logging and telemetry.

C#
public static void AddKeyedAzureKeyVaultClient(this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string name, Action<Aspire.Azure.Security.KeyVault.AzureSecurityKeyVaultSettings>? configureSettings = default, Action<Azure.Core.Extensions.IAzureClientBuilder<Azure.Security.KeyVault.Secrets.SecretClient,Azure.Security.KeyVault.Secrets.SecretClientOptions>>? configureClientBuilder = default);

Parameters

builder
IHostApplicationBuilder

The IHostApplicationBuilder to read config from and add services to.

name
String

The name of the component, which is used as the ServiceKey of the service and also to retrieve the connection information from the ConnectionStrings configuration section.

configureSettings
Action<AzureSecurityKeyVaultSettings>

An optional method that can be used for customizing the AzureSecurityKeyVaultSettings. It's invoked after the settings are read from the configuration.

configureClientBuilder
Action<IAzureClientBuilder<SecretClient,SecretClientOptions>>

An optional method that can be used for customizing the IAzureClientBuilder<TClient,TOptions>.

Exceptions

Thrown when mandatory VaultUri is not provided.

Remarks

Reads the configuration from "Aspire:Azure:Security:KeyVault:{name}" section.

Applies to

Product Versions
.NET Aspire 8.0.0, 9.0.0, 9.1.0