Skip to content

Commit

Permalink
Allow option customization for keyvault configuration provider
Browse files Browse the repository at this point in the history
  • Loading branch information
asimmon committed Aug 19, 2022
1 parent f775567 commit acf57e3
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@ public static IServiceCollection AddKeyVaultSecrets(this IServiceCollection serv
return services;
}

public static IConfigurationBuilder AddKeyVaultSecrets(this IConfigurationBuilder builder, IHostEnvironment environment, KeyVaultKind keyVaultKind = KeyVaultKind.ApplicationConfiguration)
public static IConfigurationBuilder AddKeyVaultSecrets(
this IConfigurationBuilder builder,
IHostEnvironment environment,
AzureKeyVaultConfigurationOptions? options = null,
KeyVaultKind keyVaultKind = KeyVaultKind.ApplicationConfiguration)
{
var secretClient = new SecretClientProvider(builder, environment).GetSecretClient(keyVaultKind);
return builder.AddAzureKeyVault(secretClient, new KeyVaultSecretManager());
return builder.AddAzureKeyVault(secretClient, options ?? new AzureKeyVaultConfigurationOptions());
}

public static IConfigurationBuilder AddKeyVaultSecrets(this IConfigurationBuilder builder, IHostEnvironment environment, Uri keyVaultUri)
public static IConfigurationBuilder AddKeyVaultSecrets(this IConfigurationBuilder builder, IHostEnvironment environment, Uri keyVaultUri, AzureKeyVaultConfigurationOptions? options = null)
{
var secretClient = new SecretClientProvider(builder, environment).GetSecretClient(keyVaultUri);
return builder.AddAzureKeyVault(secretClient, new KeyVaultSecretManager());
return builder.AddAzureKeyVault(secretClient, options ?? new AzureKeyVaultConfigurationOptions());
}

public static IConfigurationBuilder AddKeyVaultSecrets(this IConfigurationBuilder builder, IHostEnvironment environment, string configurationKey)
public static IConfigurationBuilder AddKeyVaultSecrets(this IConfigurationBuilder builder, IHostEnvironment environment, string configurationKey, AzureKeyVaultConfigurationOptions? options = null)
{
var secretClient = new SecretClientProvider(builder, environment).GetSecretClient(configurationKey);
return builder.AddAzureKeyVault(secretClient, new KeyVaultSecretManager());
return builder.AddAzureKeyVault(secretClient, options ?? new AzureKeyVaultConfigurationOptions());
}
}

0 comments on commit acf57e3

Please sign in to comment.