-
Notifications
You must be signed in to change notification settings - Fork 3
/
SecretsManager.cs
28 lines (24 loc) · 1020 Bytes
/
SecretsManager.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
28
using Microsoft.Azure.KeyVault;
using Shop.WebApi.AzureUtilities;
using System.Threading.Tasks;
namespace Shop.WebApi.DataAccess
{
public static class SecretsManager
{
private static string TableStorageConnectionString { get; set; }
public static async Task<string> GetTableStorageConnectionStringAsync()
{
if (TableStorageConnectionString == null)
{
TableStorageConnectionString = await RefreshSecretsInternalAsync();
}
return TableStorageConnectionString;
}
private static async Task<string> RefreshSecretsInternalAsync()
{
var kv = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(ActiveDirectoryAccessTokenHelper.GetToken));
var tableStorageConnectionStringSecret = await kv.GetSecretAsync("https://mssummitvie-prepare.vault.azure.net/", "SAS-TechnicalSummit-TableStorage");
return tableStorageConnectionStringSecret.Value;
}
}
}