Skip to content

Instantly share code, notes, and snippets.

@TechWatching
Last active January 28, 2020 10:46
Show Gist options
  • Save TechWatching/6d71663e44931acf43e8c7fb7cdecf00 to your computer and use it in GitHub Desktop.
Save TechWatching/6d71663e44931acf43e8c7fb7cdecf00 to your computer and use it in GitHub Desktop.
BuildWebHost with KeyVault and client credentials
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureAppConfiguration((builderContext, config) =>
{
var env = hostingContext.HostingEnvironment;
var builtConfig = config.Build();
var vaultUrl = $"https://{buiItConfig["VaultName"]}.vault.azure.net/";
if (env.IsDevelopment())
{
config.AddAzureKeyVault(vaultUrl);
}
else
{
config.AddAzureKeyVault(vaultUrl, builtConfig[ "clientld"], builtConfig["clientSecret"]);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment