VS2019 Docker ASP Core Environment Vars

Tip

If you are debugging with VS2017/9 and want to pass environment variables to your container then read this post, if you are looking for picture of cats then sorry but leave a comment how you got here

 

Step 1

Create a new text file, the name doesn’t matter, but i called mine Dockerfile.env

image
image

 

Step 2

Add this file to your .csproj file.

image

Step 3

Not really a step but you you can simply query your Environment variable in the usual fashion (Environment.GetEnvironmentVariable())

image

 

Note:

Needless to say when you run in production you’ll need to pass the Environment variable according to Docker documentation which I don’t cover here

Comments are closed