https://github.com/mendhak/dotnet-configuration-inheritance-demo
https://github.com/mendhak/dotnet-configuration-inheritance-demo
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mendhak/dotnet-configuration-inheritance-demo
- Owner: mendhak
- Created: 2023-06-26T20:59:15.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-26T21:02:07.000Z (almost 3 years ago)
- Last Synced: 2025-04-06T00:27:40.263Z (about 1 year ago)
- Language: Dockerfile
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Sample app to demonstrate dotnet's hierarchical configuration feature, and double underscore notation to override specific configuration values.
With dotnet
```
# Reads from appsettings.json
$ dotnet run
Hello, From Default
# Reads from appsettings.staging.json
$ ENVIRONMENT_NAME=staging dotnet run
Hello, From Staging
# Reads from appsettings.production.json
$ ENVIRONMENT_NAME=production dotnet run
Hello, From Production!
# Overridden from 'external secret store'
$ SUBJECT__NAME=Dennis dotnet run
Hello, Dennis
# Overridden from 'external secret store', takes precedence over appsettings.x.json
$ ENVIRONMENT_NAME=production SUBJECT__NAME=Dennis dotnet run
Hello, Dennis
```
With Docker
```
$ docker build -t dotnetconfigdemo:latest .
$ docker run -e ENVIRONMENT_NAME=production --rm dotnetconfigdemo:latest
Hello, From Production!
$ docker run -e ENVIRONMENT_NAME=production -e SUBJECT__NAME=Harry --rm dotnetconfigdemo:latest
Hello, Harry
```