-
Notifications
You must be signed in to change notification settings - Fork 0
/
HarnessUtility.cs
27 lines (24 loc) · 1.13 KB
/
HarnessUtility.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//-----------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
using Microsoft.Azure.KeyVault;
using Microsoft.Azure.Services.AppAuthentication;
/// <summary>
/// Suite of utility methods needed for the test harness.
/// </summary>
public class HarnessUtility
{
/// <summary>
/// Method used for obtaining the Blob storage connection string from key vault.
/// </summary>
/// <param name="connectionName">The name of the connection.</param>
public static async Task<string> GetBlobStorageConnectionStringAsync(string connectionName)
{
var tokenProvider = new AzureServiceTokenProvider();
var client = new KeyVaultClient(authenticationCallback: new KeyVaultClient.AuthenticationCallback(tokenProvider.KeyVaultTokenCallback));
var secret = await client.GetSecretAsync(
vaultBaseUrl: System.Environment.GetEnvironmentVariable("HARNESS_KEY_VAULT_URL"),
secretName: connectionName).ConfigureAwait(continueOnCapturedContext: false);
return secret.Value;
}
}