Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Key Vault reading in AzureAppConfigurationBuilder (#230) #232

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Azure/AzureKeyVaultConfigBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ public override string GetValue(string key)
protected virtual TokenCredential GetCredential() => new DefaultAzureCredential();

/// <summary>
/// Gets a <see cref="SecretClientOptions"/> to initialize the Key Vault SecretClient with. This defaults to a new <see cref="SecretClientOptions"/>.
/// Gets a <see cref="SecretClientOptions"/> to initialize the Key Vault <see cref="SecretClient"/> with. This defaults to a new <see cref="SecretClientOptions"/>.
/// </summary>
/// <returns>A token credential.</returns>
/// <returns>SecretClientOptions instance.</returns>
protected virtual SecretClientOptions GetSecretClientOptions() => new SecretClientOptions();


Expand Down
15 changes: 11 additions & 4 deletions src/AzureAppConfig/AzureAppConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,22 @@ public override string GetValue(string key)
}

/// <summary>
/// Gets a <see cref="TokenCredential"/> to authenticate with App Configuration. This defaults to <see cref="DefaultAzureCredential"/>.
/// Gets a <see cref="TokenCredential"/> to authenticate with App Configuration including Key-Value references to Azure Key Vault. This defaults to <see cref="DefaultAzureCredential"/>.
/// </summary>
/// <returns>A token credential.</returns>
protected virtual TokenCredential GetCredential() => new DefaultAzureCredential();

/// <summary>
/// Gets a <see cref="ConfigurationClientOptions"/> to initialize the Key Vault SecretClient with. This defaults to a new <see cref="ConfigurationClientOptions"/>.
/// Gets a <see cref="SecretClientOptions"/> to initialize the Key Vault <see cref="SecretClient"/> with. This defaults to a new <see cref="SecretClientOptions"/>.
/// </summary>
/// <returns>A token credential.</returns>
/// <returns>A <see cref="SecretClientOptions"/> instance.</returns>
/// <remarks>The <see cref="SecretClient"/> is used here to read Azure App Configuration key-value references to Azure Key Vault.</remarks>
protected virtual SecretClientOptions GetSecretClientOptions() => new SecretClientOptions();

/// <summary>
/// Gets a <see cref="ConfigurationClientOptions"/> to initialize <see cref="ConfigurationClient"/> with. This defaults to a new <see cref="ConfigurationClientOptions"/>.
/// </summary>
/// <returns>A <see cref="ConfigurationClientOptions"/> instance.</returns>
protected virtual ConfigurationClientOptions GetConfigurationClientOptions() => new ConfigurationClientOptions();

private async Task<string> GetValueAsync(string key)
Expand Down Expand Up @@ -384,7 +391,7 @@ private async Task<string> GetKeyVaultValue(SecretReferenceConfigurationSetting

private SecretClient GetSecretClient(KeyVaultSecretIdentifier identifier)
{
return _kvClientCache.GetOrAdd(identifier.VaultUri, uri => new SecretClient(identifier.VaultUri, new DefaultAzureCredential()));
return _kvClientCache.GetOrAdd(identifier.VaultUri, uri => new SecretClient(identifier.VaultUri, GetCredential(), GetSecretClientOptions()));
}
}
}