public async Task<string> GetAsync(string key)
{
string value;
if (!_keyedSettings.TryGetValue(key, out value))
{
if (_localConfiguration != null)
{
value = _localConfiguration[key];
}
if (string.IsNullOrWhiteSpace(value) && !_isPreloaded)
{
try
{
string keyVaultEncodedKey = _keyEncoder.Encode(key);
value = await _vault.GetSecretAsync(keyVaultEncodedKey);
}
catch (AggregateException ex)
{
KeyVaultClientException kex = ex.InnerExceptions.FirstOrDefault() as KeyVaultClientException;
if (kex != null && kex.Status == HttpStatusCode.NotFound)
{
value = null;
}
else
{
throw;
}
}
}
_keyedSettings.AddOrUpdate(key, value, (s, s1) => value);
}
return value;
}