-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
37 lines (32 loc) · 1.56 KB
/
Program.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
29
30
31
32
33
34
35
36
37
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
namespace questions4me_apirestful_net
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.ConfigureAppConfiguration((ContextBoundObject, config) => {
// Build the current set of configuration to load values from
// JSON files and environment variables, including VaultName.
var builtConfig = config.Build();
// Use VaultName from the configuration to create the full vault URL.
var vaultUrl = $"https://{builtConfig["KeyVaultName"]}.vault.azure.net/";
// Load all secrets from the vault into configuration. This will automatically
// authenticate to the vault using a managed identity. If a managed identity
// is not available, it will check if Visual Studio and/or the Azure CLI are
// installed locally and see if they are configured with credentials that can
// access the vault.
config.AddAzureKeyVault(vaultUrl);
});
}
}