public async Task<string> GetSecretAsync(string key)
{
try
{
if (_checkIfKeyExistsBeforeGet)
{
IReadOnlyCollection<string> keys = await GetSecretKeysAsync();
if (!keys.Contains(key))
{
return null;
}
}
Secret secret = await _keyVaultClient.GetSecretAsync(_vaultUri, key);
return secret.Value;
}
catch (KeyVaultClientException kex)
{
if (kex.Error.Code == "SecretNotFound")
{
return null;
}
throw;
}
}