-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuring with Environment Variables #4927
Comments
Coverage for setting them for the environment is in the Working with multiple environments topic, so there is some coverage on what to do on various platforms and with VS (but not VSC 😢). I'd point out tho that setting env vars generally might be better over in the .NET Core docs, as it feels more like a tooling/platform area activity rather than a web app programming activity. btw -- I was just wondering something: https://github.com/dotnet/cli/issues/8179 |
Thanks for replying @guardrex.
That documentation seems to only focus on setting the ASPNETCORE_ENVIRONMENT environment variable and not overriding/setting custom configuration using environment variables.
In my case I'm thinking about setting values which I can then access via IOptions. That feels ASP.NET specific. I'm don't think it would be a big document (any maybe just needs clarifying on the existing docs). Mostly I think the use of double underscore vs colon needs to be promoted as the best (safest) practice since it works on any OS. @DamianEdwards did point out on the community standup that there a one line reference to this on https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?tabs=basicconfiguration within the Configuration considerations section. I'm wondering if it can be called out more prominently.
This sounds interesting. In our case I'm not sure if it would totally help. We're generally setting env vars when starting containers using docker-compose or some Cloud based mechanism. This allows instances to use the same image but run with different configuration for different deployment environments. So in this issue case I was thinking more about the advice of using __ as a general rule when setting values, however you choose to do that. |
That would be a significant guidance shift. However, taking that bullet point that pertains to the use of the double-underscore and making a dedicated section out of it might be welcome. SGTM |
Fair enough on the guidance. If the docs can make the underscore option a little more obvious hopefully that will help developers pick the correct option. |
I think so ... I marked that issue as a dup of (or very closely related to) this one. @rachelappel has these, so she'll take care of it. |
If @rachelappel is working on them, why are they up-for-grabs :) |
That should be an oversight. We usually pull the label when the issue is assigned. However, I'll let her do that, since I'm not sure what the status is on this one. I just know it isn't on my plate at the moment. 😅 |
@isaac2004 I'll be unassigning that one. It's really up for grabs. |
@rachelappel @scottaddie can we close this issue since #4968 is closed? |
Fixed by #5876 |
New topic suggestion
I'd like to propose some basic documentation be added around using environment variables for configuration that describes things such as the format of the key to be used.
I recently experience an issue around changes between running on Debian Stretch vs Debian Jessie that I documented here: https://www.stevejgordon.co.uk/asp-net-core-gotchas-number-1
I could not find any existing documentation to specifically how environment variables are expected to be set.
Possibly this extends https://github.com/aspnet/Docs/blob/master/aspnetcore/fundamentals/configuration/index.md or is a sub-page linked from the index.
If this sounds useful I would like to try to find time to support outlining a more detailed contents for this topic.
The text was updated successfully, but these errors were encountered: