Skip to content

Instantly share code, notes, and snippets.

@CalvinAllen
Created February 16, 2022 22:14
Show Gist options
  • Save CalvinAllen/7229589af1e25dddf8eccbe114d8b994 to your computer and use it in GitHub Desktop.
Save CalvinAllen/7229589af1e25dddf8eccbe114d8b994 to your computer and use it in GitHub Desktop.
Using ConfigurationBuilder
var configBuilder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile($"appsettings.{environment}.json", optional: true);
if (environment == EnvironmentEnum.LocalDevelopment)
{
configBuilder.AddUserSecrets<Function>(optional: true);
}
configBuilder.AddEnvironmentVariables();
var configuration = configBuilder.Build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment