Last active
March 9, 2016 15:31
-
-
Save michielpost/ba428ec9741cbb7ed4c2 to your computer and use it in GitHub Desktop.
ASP.Net Core 1.0 configuration per developer
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
///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