AccidentalFish.ApplicationSupport.Azure.KeyVault.Implementation.KeyVault.GetSecretAsync C# (CSharp) Method

GetSecretAsync() public method

public GetSecretAsync ( string key ) : Task
key string
return Task
        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;
            }            
        }