source/TestCommon/source/FunctionApp.TestCommon/Configuration/IConfigurationBuilderExtensions.cs
/// <summary>
/// Adds an <see cref="IConfigurationProvider"/> that reads configuration values from the Azure KeyVault.
///
/// Using <see cref="DefaultAzureCredential"/> it automatically requests access tokens for reading
/// from the Key Vault. For this to work the identity under which the tests are executied, must have
/// Get and List permissions to secrets in the Key Vault.
/// </summary>
/// <param name="builder">The configuration builder.</param>
/// <param name="keyVaultUrl">KeyVault URL eg. https://myexamplekeyvault.vault.azure.net/</param>
Adds an  that reads configuration values from the Azure KeyVault.

Using  it automatically requests access tokens for reading
from the Key Vault. For this to work the identity under which the tests are executied, must have
Get and List permissions to secrets in the Key Vault.
Adds an that reads configuration values from the Azure KeyVault . Using it automatically requests access tokens for reading from the Key Vault . For this to work the identity under which the tests are executied must have Get and List permissions to secrets in the Key Vault .
public static IConfigurationBuilder AddAuthenticatedAzureKeyVault(this IConfigurationBuilder builder, string keyVaultUrl)
        {
            if (string.IsNullOrEmpty(keyVaultUrl))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(keyVaultUrl));
            }
            var credential = new DefaultAzureCredential();
            builder.AddAzureKeyVault(new Uri(keyVaultUrl), credential);
            return builder;
        }
public static IConfigurationBuilder AddAuthenticatedAzureKeyVault ( this IConfigurationBuilder builder , string keyVaultUrl ) { if ( string . IsNullOrEmpty ( keyVaultUrl ) ) { throw new ArgumentException ( " " , nameof ( keyVaultUrl ) ) ; } var credential = new DefaultAzureCredential ( ) ; builder . AddAzureKeyVault ( new Uri ( keyVaultUrl ) , credential ) ; return builder ; }
Adds an  that reads configuration values from the Azure KeyVault.
Adds an that reads configuration values from the Azure KeyVault .
IConfigurationBuilder
this
keyVaultUrl
string
KeyVault URL eg.
KeyVault URL eg .
builder
The configuration builder.
The configuration builder .