Last active
December 6, 2019 16:10
-
-
Save ljtill/8fd86d8dda2643a740376f207cd32cbc to your computer and use it in GitHub Desktop.
Provides the ability to retrieve a secret from Key Vault
This file contains hidden or 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
| private static async Task<string> GetSecret(string uri, string name) | |
| { | |
| /// <summary> | |
| /// Secret retrieval via Managed Service Identity (MSI). | |
| /// Link: https://docs.microsoft.com/en-us/azure/active-directory/managed-service-identity/overview | |
| /// </summary> | |
| AzureServiceTokenProvider provider = new AzureServiceTokenProvider(); | |
| KeyVaultClient client = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(provider.KeyVaultTokenCallback)); | |
| SecretBundle secret = await client.GetSecretAsync((uri + $"/Secrets/{name}")); | |
| string value = secret.Value; | |
| return value; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment