Created
June 10, 2019 04:17
-
-
Save kasunkv/65e32c83d77b088ee5230a533e793325 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 IWebHostBuilder CreateWebHostBuilder(string[] args) => | |
WebHost.CreateDefaultBuilder(args) | |
.ConfigureAppConfiguration((ctx, config) => { | |
// Fetch app settings from Azure Key Vault if its in production mode. | |
if (ctx.HostingEnvironment.IsProduction()) | |
{ | |
var configRoot = config.Build(); | |
var tokenProvider = new AzureServiceTokenProvider(); | |
config.AddAzureKeyVault( | |
$"https://{configRoot["AppSettings:KeyVaultName"]}.vault.azure.net/", | |
new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(tokenProvider.KeyVaultTokenCallback)), | |
new DefaultKeyVaultSecretManager()); | |
} | |
}) | |
.UseStartup<Startup>(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment