Sdílet prostřednictvím


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.

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);
static member AddKeyedAzureKeyVaultClient : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.Azure.Security.KeyVault.AzureSecurityKeyVaultSettings> * Action<Azure.Core.Extensions.IAzureClientBuilder<Azure.Security.KeyVault.Secrets.SecretClient, Azure.Security.KeyVault.Secrets.SecretClientOptions>> -> unit
<Extension()>
Public Sub AddKeyedAzureKeyVaultClient (builder As IHostApplicationBuilder, name As String, Optional configureSettings As Action(Of AzureSecurityKeyVaultSettings) = Nothing, Optional configureClientBuilder As Action(Of IAzureClientBuilder(Of SecretClient, SecretClientOptions)) = Nothing)

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