From acf57e325bebaacb70cd4fbd69eadf7b24949233 Mon Sep 17 00:00:00 2001 From: Anthony Simmon Date: Fri, 19 Aug 2022 12:02:20 -0400 Subject: [PATCH] Allow option customization for keyvault configuration provider --- .../ServiceCollectionExtensions.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ShareGate.Extensions.Configuration.Secrets/ServiceCollectionExtensions.cs b/src/ShareGate.Extensions.Configuration.Secrets/ServiceCollectionExtensions.cs index 0ddedeb..b593751 100644 --- a/src/ShareGate.Extensions.Configuration.Secrets/ServiceCollectionExtensions.cs +++ b/src/ShareGate.Extensions.Configuration.Secrets/ServiceCollectionExtensions.cs @@ -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()); } } \ No newline at end of file