Skip to content

Demo showing how to do environment specific configuration in .Net Core

License

Notifications You must be signed in to change notification settings

lukemerrett/EnvironmentConfigSample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Environment Config Sample

Demo showing how to do environment specific configuration in .Net Core

Introduction

In the EnvironmentConfig/Config folder are three files:

  • appsettings.json
  • appsettings.Staging.CA.json
  • appsettings.Staging.UK.json

The ConfigurationLoader class is set up using the new ConfigurationBuilder logic in .Net Core to load these files based on the programs arguments.

The appsettings.json is the default, whilst any keys present in the overrides like appsettings.Staging.CA.json will overwrite the defaults for us.

The arguments specifying which environment and tenant we are in are passed to the program, e.g:

dotnet run Staging CA

Prerequisites

Setup

Run the following in the EnvironmentConfig project folder:

dotnet restore
dotnet build

Running The Application

Run the following in the EnvironmentConfig project folder.

To use the default appsettings.json config with no environment or tenant overrides, use:

dotnet run

To pass in the environment and tenant to override the default configuration, use:

dotnet run Staging CA

About

Demo showing how to do environment specific configuration in .Net Core

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages