共用方式為


AspireKeyVaultExtensions.AddAzureKeyVaultClient Method

Definition

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

public static void AddAzureKeyVaultClient (this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string connectionName, 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 AddAzureKeyVaultClient : 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 AddAzureKeyVaultClient (builder As IHostApplicationBuilder, connectionName 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.

connectionName
String

A name used to retrieve the connection string 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" section.

Applies to