Last active
January 28, 2020 10:46
-
-
Save TechWatching/6d71663e44931acf43e8c7fb7cdecf00 to your computer and use it in GitHub Desktop.
BuildWebHost with KeyVault and client credentials
This file contains 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
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