I have the following nested data in the appsettings.json
:
{
"Jwt": {
"PublicKey": "...",
"PrivateKey": "..."
},
...
}
And the goal is to run this app in WSL/Docker/etc. so basically I want to override this config nested with environment variables
I've tried to use "Jwt:PublicKey"
as a variable name, but it doesn't work.
What is the general approach for the env vars storage the way they're able to be mapped to nested configuration?
P.S. actually I store keys in user secrets (secrets.json
), but it's kind of irrelevant to the question.
CodePudding user response:
According to MSDN you can set environment variables like this: Jwt__PublicKey
.
This would go in your Dockerfile
under environment
section:
environment:
- Jwt__PublicKey=publickey
- Jwt__PrivateKey=...