Skip to content
DocsTry Aspire
DocsTry

AspireKeyVaultExtensions Methods

ClassMethods7 members
Provides extension methods for registering and configuring Azure Key Vault secrets in an Aspire application.
AddAzureKeyVaultCertificateClient(IHostApplicationBuilder, string, Action<AzureSecurityKeyVaultSettings>, Action<IAzureClientBuilder<CertificateClient, CertificateClientOptions>>)Section titled AddAzureKeyVaultCertificateClient(IHostApplicationBuilder, string, Action<AzureSecurityKeyVaultSettings>, Action<IAzureClientBuilder<CertificateClient, CertificateClientOptions>>)extension
Registers Certificates.CertificateClient as a singleton in the services provided by the builder.
public static class AspireKeyVaultExtensions
{
public static void AddAzureKeyVaultCertificateClient(
this IHostApplicationBuilder builder,
string connectionName,
Action<AzureSecurityKeyVaultSettings>? configureSettings = null,
Action<IAzureClientBuilder<CertificateClient, CertificateClientOptions>>? configureClientBuilder = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
connectionNamestringA name used to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<AzureSecurityKeyVaultSettings>optionalAn optional method that can be used for customizing the AzureSecurityKeyVaultSettings. It's invoked after the settings are read from the configuration.
configureClientBuilderAction<IAzureClientBuilder<CertificateClient, CertificateClientOptions>>optionalAn optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
InvalidOperationExceptionThrown when mandatory AzureSecurityKeyVaultSettings.VaultUri is not provided.
Reads the configuration from "Aspire:Azure:Security:KeyVault:{name}" section.
AddAzureKeyVaultClient(IHostApplicationBuilder, string, Action<AzureSecurityKeyVaultSettings>, Action<IAzureClientBuilder<SecretClient, SecretClientOptions>>)Section titled AddAzureKeyVaultClient(IHostApplicationBuilder, string, Action<AzureSecurityKeyVaultSettings>, Action<IAzureClientBuilder<SecretClient, SecretClientOptions>>)extension
Registers Secrets.SecretClient as a singleton in the services provided by the builder. Enables retries, corresponding health check, logging and telemetry.
public static class AspireKeyVaultExtensions
{
public static void AddAzureKeyVaultClient(
this IHostApplicationBuilder builder,
string connectionName,
Action<AzureSecurityKeyVaultSettings>? configureSettings = null,
Action<IAzureClientBuilder<SecretClient, SecretClientOptions>>? configureClientBuilder = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
connectionNamestringA name used to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<AzureSecurityKeyVaultSettings>optionalAn optional method that can be used for customizing the AzureSecurityKeyVaultSettings. It's invoked after the settings are read from the configuration.
configureClientBuilderAction<IAzureClientBuilder<SecretClient, SecretClientOptions>>optionalAn optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
InvalidOperationExceptionThrown when mandatory AzureSecurityKeyVaultSettings.VaultUri is not provided.
Reads the configuration from "Aspire:Azure:Security:KeyVault" section.
AddAzureKeyVaultKeyClient(IHostApplicationBuilder, string, Action<AzureSecurityKeyVaultSettings>, Action<IAzureClientBuilder<KeyClient, KeyClientOptions>>)Section titled AddAzureKeyVaultKeyClient(IHostApplicationBuilder, string, Action<AzureSecurityKeyVaultSettings>, Action<IAzureClientBuilder<KeyClient, KeyClientOptions>>)extension
Registers Keys.KeyClient as a singleton in the services provided by the builder.
public static class AspireKeyVaultExtensions
{
public static void AddAzureKeyVaultKeyClient(
this IHostApplicationBuilder builder,
string connectionName,
Action<AzureSecurityKeyVaultSettings>? configureSettings = null,
Action<IAzureClientBuilder<KeyClient, KeyClientOptions>>? configureClientBuilder = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
connectionNamestringA name used to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<AzureSecurityKeyVaultSettings>optionalAn optional method that can be used for customizing the AzureSecurityKeyVaultSettings. It's invoked after the settings are read from the configuration.
configureClientBuilderAction<IAzureClientBuilder<KeyClient, KeyClientOptions>>optionalAn optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
InvalidOperationExceptionThrown when mandatory AzureSecurityKeyVaultSettings.VaultUri is not provided.
Reads the configuration from "Aspire:Azure:Security:KeyVault:{name}" section.
AddAzureKeyVaultSecrets(IConfigurationManager, string, Action<AzureSecurityKeyVaultSettings>, Action<SecretClientOptions>, AzureKeyVaultConfigurationOptions?)Section titled AddAzureKeyVaultSecrets(IConfigurationManager, string, Action<AzureSecurityKeyVaultSettings>, Action<SecretClientOptions>, AzureKeyVaultConfigurationOptions?)extension
Adds the Azure KeyVault secrets to be configuration values in the configurationManager.
public static class AspireKeyVaultExtensions
{
public static void AddAzureKeyVaultSecrets(
this IConfigurationManager configurationManager,
string connectionName,
Action<AzureSecurityKeyVaultSettings>? configureSettings = null,
Action<SecretClientOptions>? configureClientOptions = null,
AzureKeyVaultConfigurationOptions? options = null)
{
// ...
}
}
configurationManagerIConfigurationManagerThe Configuration.IConfigurationManager to add the secrets to.
connectionNamestringA name used to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<AzureSecurityKeyVaultSettings>optionalAn optional method that can be used for customizing the AzureSecurityKeyVaultSettings. It's invoked after the settings are read from the configuration.
configureClientOptionsAction<SecretClientOptions>optionalAn optional method that can be used for customizing the Secrets.SecretClientOptions.
optionsAzureKeyVaultConfigurationOptions?optionalAn optional Secrets.AzureKeyVaultConfigurationOptions instance to configure the behavior of the configuration provider.
AddKeyedAzureKeyVaultCertificateClient(IHostApplicationBuilder, string, Action<AzureSecurityKeyVaultSettings>, Action<IAzureClientBuilder<CertificateClient, CertificateClientOptions>>)Section titled AddKeyedAzureKeyVaultCertificateClient(IHostApplicationBuilder, string, Action<AzureSecurityKeyVaultSettings>, Action<IAzureClientBuilder<CertificateClient, CertificateClientOptions>>)extension
Registers Certificates.CertificateClient as a singleton for given name in the services provided by the builder.
public static class AspireKeyVaultExtensions
{
public static void AddKeyedAzureKeyVaultCertificateClient(
this IHostApplicationBuilder builder,
string name,
Action<AzureSecurityKeyVaultSettings>? configureSettings = null,
Action<IAzureClientBuilder<CertificateClient, CertificateClientOptions>>? configureClientBuilder = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
namestringThe name of the component, which is used as the ServiceDescriptor.ServiceKey of the service and also to retrieve the connection information from the ConnectionStrings configuration section.
configureSettingsAction<AzureSecurityKeyVaultSettings>optionalAn optional method that can be used for customizing the AzureSecurityKeyVaultSettings. It's invoked after the settings are read from the configuration.
configureClientBuilderAction<IAzureClientBuilder<CertificateClient, CertificateClientOptions>>optionalAn optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
InvalidOperationExceptionThrown when mandatory AzureSecurityKeyVaultSettings.VaultUri is not provided.
Reads the configuration from "Aspire:Azure:Security:KeyVault:{name}" section.
AddKeyedAzureKeyVaultClient(IHostApplicationBuilder, string, Action<AzureSecurityKeyVaultSettings>, Action<IAzureClientBuilder<SecretClient, SecretClientOptions>>)Section titled AddKeyedAzureKeyVaultClient(IHostApplicationBuilder, string, Action<AzureSecurityKeyVaultSettings>, Action<IAzureClientBuilder<SecretClient, SecretClientOptions>>)extension
Registers Secrets.SecretClient as a singleton for given name in the services provided by the builder. Enables retries, corresponding health check, logging and telemetry.
public static class AspireKeyVaultExtensions
{
public static void AddKeyedAzureKeyVaultClient(
this IHostApplicationBuilder builder,
string name,
Action<AzureSecurityKeyVaultSettings>? configureSettings = null,
Action<IAzureClientBuilder<SecretClient, SecretClientOptions>>? configureClientBuilder = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
namestringThe name of the component, which is used as the ServiceDescriptor.ServiceKey of the service and also to retrieve the connection information from the ConnectionStrings configuration section.
configureSettingsAction<AzureSecurityKeyVaultSettings>optionalAn optional method that can be used for customizing the AzureSecurityKeyVaultSettings. It's invoked after the settings are read from the configuration.
configureClientBuilderAction<IAzureClientBuilder<SecretClient, SecretClientOptions>>optionalAn optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
InvalidOperationExceptionThrown when mandatory AzureSecurityKeyVaultSettings.VaultUri is not provided.
Reads the configuration from "Aspire:Azure:Security:KeyVault:{name}" section.
AddKeyedAzureKeyVaultKeyClient(IHostApplicationBuilder, string, Action<AzureSecurityKeyVaultSettings>, Action<IAzureClientBuilder<KeyClient, KeyClientOptions>>)Section titled AddKeyedAzureKeyVaultKeyClient(IHostApplicationBuilder, string, Action<AzureSecurityKeyVaultSettings>, Action<IAzureClientBuilder<KeyClient, KeyClientOptions>>)extension
Registers Keys.KeyClient as a singleton for given name in the services provided by the builder.
public static class AspireKeyVaultExtensions
{
public static void AddKeyedAzureKeyVaultKeyClient(
this IHostApplicationBuilder builder,
string name,
Action<AzureSecurityKeyVaultSettings>? configureSettings = null,
Action<IAzureClientBuilder<KeyClient, KeyClientOptions>>? configureClientBuilder = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
namestringThe name of the component, which is used as the ServiceDescriptor.ServiceKey of the service and also to retrieve the connection information from the ConnectionStrings configuration section.
configureSettingsAction<AzureSecurityKeyVaultSettings>optionalAn optional method that can be used for customizing the AzureSecurityKeyVaultSettings. It's invoked after the settings are read from the configuration.
configureClientBuilderAction<IAzureClientBuilder<KeyClient, KeyClientOptions>>optionalAn optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
InvalidOperationExceptionThrown when mandatory AzureSecurityKeyVaultSettings.VaultUri is not provided.
Reads the configuration from "Aspire:Azure:Security:KeyVault:{name}" section.