Created
October 10, 2019 18:17
-
-
Save davidbreyer/6372376e70534a050fd30ef44aa2cf7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Azure.KeyVault; | |
using Microsoft.Azure.Services.AppAuthentication; | |
using System; | |
using System.Threading.Tasks; | |
namespace YourNameSpace | |
{ | |
public class VaultAccess | |
{ | |
public async Task<string> GetSecretKey(string secretKeyEndPoint) | |
{ | |
try | |
{ | |
AzureServiceTokenProvider azureServiceTokenProvider = new AzureServiceTokenProvider(); | |
KeyVaultClient keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback)); | |
var secret = await keyVaultClient.GetSecretAsync(secretKeyEndPoint) | |
.ConfigureAwait(false); | |
return secret.Value; | |
} | |
catch (Exception) | |
{ | |
return null; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment