Skip to content

Commit 0309df8

Browse files
Add overload for SecretClientOptions and ConfigurationClientOptions. (#201) (#207)
Co-authored-by: Benjamin Vanderlinde <[email protected]>
1 parent 7e6c931 commit 0309df8

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/Azure/AzureKeyVaultConfigBuilder.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ protected override void LazyInitialize(string name, NameValueCollection config)
122122
// Connect to KeyVault
123123
try
124124
{
125-
_kvClient = new SecretClient(new Uri(Uri), GetCredential());
125+
_kvClient = new SecretClient(new Uri(Uri), GetCredential(), GetSecretClientOptions());
126126
}
127127
catch (Exception)
128128
{
@@ -164,6 +164,14 @@ public override string GetValue(string key)
164164
/// </summary>
165165
/// <returns>A token credential.</returns>
166166
protected virtual TokenCredential GetCredential() => new DefaultAzureCredential();
167+
168+
/// <summary>
169+
/// Gets a <see cref="SecretClientOptions"/> to initialize the Key Vault SecretClient with. This defaults to <see cref="null"/>.
170+
/// </summary>
171+
/// <returns>A token credential.</returns>
172+
protected virtual SecretClientOptions GetSecretClientOptions() => null;
173+
174+
167175

168176
/// <summary>
169177
/// Retrieves all known key/value pairs from the Key Vault where the key begins with with <paramref name="prefix"/>.

src/AzureAppConfig/AzureAppConfigurationBuilder.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ protected override void LazyInitialize(string name, NameValueCollection config)
114114
try
115115
{
116116
var uri = new Uri(Endpoint);
117-
_client = new ConfigurationClient(uri, GetCredential());
117+
_client = new ConfigurationClient(uri, GetCredential(), GetConfigurationClientOptions());
118118
}
119119
catch (Exception ex)
120120
{
@@ -225,6 +225,12 @@ public override ICollection<KeyValuePair<string, string>> GetAllValues(string pr
225225
/// </summary>
226226
/// <returns>A token credential.</returns>
227227
protected virtual TokenCredential GetCredential() => new DefaultAzureCredential();
228+
229+
/// <summary>
230+
/// Gets a <see cref="ConfigurationClientOptions"/> to initialize the Key Vault SecretClient with. This defaults to <see cref="null"/>.
231+
/// </summary>
232+
/// <returns>A token credential.</returns>
233+
protected virtual ConfigurationClientOptions GetConfigurationClientOptions() => null;
228234

229235
private async Task<string> GetValueAsync(string key)
230236
{

0 commit comments

Comments
 (0)