Skip to content

Instantly share code, notes, and snippets.

View TechWatching's full-sized avatar

Alexandre Nédélec TechWatching

View GitHub Profile
@TechWatching
TechWatching / BuildWebHostWithMSI.cs
Created February 17, 2019 16:05
WebHost with MSI (no client credentials)
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureAppConfiguration((builderContext, config) =>
{
var builtConfig = config.Build();
var vaultUrl = $"https://{buiItConfig["VaultName"]}.vault.azure.net/";
config.AddAzureKeyVault(vaultUrl);
});
@TechWatching
TechWatching / BuildWebHost.cs
Last active January 28, 2020 10:46
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())
@TechWatching
TechWatching / KeyVault.Program.cs
Last active January 28, 2020 11:04
Nouveau projet ASP.NET Core 2.2
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}