Skip to content

Instantly share code, notes, and snippets.

@michielpost
Last active March 9, 2016 15:31
Show Gist options
  • Save michielpost/ba428ec9741cbb7ed4c2 to your computer and use it in GitHub Desktop.
Save michielpost/ba428ec9741cbb7ed4c2 to your computer and use it in GitHub Desktop.
ASP.Net Core 1.0 configuration per developer
///NCONFIG_ALIAS is set in Azure as Environment variable
var configAlias = Environment.GetEnvironmentVariable("NCONFIG_ALIAS");
if(string.IsNullOrEmpty(configAlias)) //Use the computer name for default custom config
configAlias = Environment.GetEnvironmentVariable("COMPUTERNAME");
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.SetBasePath(appEnv.ApplicationBasePath)
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) //http://docs.asp.net/en/latest/fundamentals/environments.html
.AddJsonFile(Path.Combine("Configuration", $"appsettings.{configAlias}.json"), optional: true)
.AddEnvironmentVariables();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment