Skip to content

Instantly share code, notes, and snippets.

@MisinformedDNA
Created June 11, 2018 22:35
Show Gist options
  • Save MisinformedDNA/6cd6117389792d91d1862f8954d4afd8 to your computer and use it in GitHub Desktop.
Save MisinformedDNA/6cd6117389792d91d1862f8954d4afd8 to your computer and use it in GitHub Desktop.
ASP.NET Core with Azure Key Vault configuration provider
using Microsoft.Extensions.Configuration;
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, config) =>
{
var builtConfig = config.Build();
var keyVaultConfigBuilder = new ConfigurationBuilder();
keyVaultConfigBuilder.AddAzureKeyVault(
$"https://{builtConfig["Vault"]}.vault.azure.net/",
builtConfig["ClientId"],
builtConfig["ClientSecret"]);
var keyVaultConfig = keyVaultConfigBuilder.Build();
config.AddConfiguration(keyVaultConfig);
})
.UseStartup<Startup>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment