Skip to content

About

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

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

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

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages