Skip to content
Docs Try Aspire

AspireKeyVaultExtensions Methods

Class Methods 7 members
Provides extension methods for registering and configuring Azure Key Vault secrets in a .NET 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)
{
// ...
}
}
builder IHostApplicationBuilder The Hosting.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> optional 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<CertificateClient, CertificateClientOptions>> optional An optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
InvalidOperationException Thrown 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)
{
// ...
}
}
builder IHostApplicationBuilder The Hosting.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> optional 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>> optional An optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
InvalidOperationException Thrown 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)
{
// ...
}
}
builder IHostApplicationBuilder The Hosting.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> optional 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<KeyClient, KeyClientOptions>> optional An optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
InvalidOperationException Thrown 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)
{
// ...
}
}
configurationManager IConfigurationManager The Configuration.IConfigurationManager to add the secrets to.
connectionName string A name used to retrieve the connection string from the ConnectionStrings configuration section.
configureSettings Action<AzureSecurityKeyVaultSettings> optional An optional method that can be used for customizing the AzureSecurityKeyVaultSettings. It's invoked after the settings are read from the configuration.
configureClientOptions Action<SecretClientOptions> optional An optional method that can be used for customizing the Secrets.SecretClientOptions.
options AzureKeyVaultConfigurationOptions? optional An 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)
{
// ...
}
}
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.
name string The 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.
configureSettings Action<AzureSecurityKeyVaultSettings> optional 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<CertificateClient, CertificateClientOptions>> optional An optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
InvalidOperationException Thrown 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)
{
// ...
}
}
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.
name string The 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.
configureSettings Action<AzureSecurityKeyVaultSettings> optional 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>> optional An optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
InvalidOperationException Thrown 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)
{
// ...
}
}
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.
name string The 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.
configureSettings Action<AzureSecurityKeyVaultSettings> optional 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<KeyClient, KeyClientOptions>> optional An optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
InvalidOperationException Thrown when mandatory AzureSecurityKeyVaultSettings.VaultUri is not provided.
Reads the configuration from "Aspire:Azure:Security:KeyVault:{name}" section.