-
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
The hostcontext did not have the environment variable information in … #10531
Conversation
…ConfigureAppConfiguration. ConfigureHostConfiguration must be called first
Hello @mattspicer1 ... Correct! ... especially given we tossed in consumption of the environmental appsettings file.
First, two little things ...
Here's a ❓ for @Tratcher ...
If we go with Option 3 ...
Thing is tho that the upcoming templates won't do all of this, correct? Anywho ... wrt the PR here ... @Tratcher, what would u like to do? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why you'd do number 3, It's better to let the host build the config.
Command line args do flow, CreateDefaultBuilder adds them twice to preserve precedence over lower priority config sources.
See the new template for 3.0 preview2 https://github.com/aspnet/AspNetCore/blob/e004e5aab29dc26beaafaed49c7aa4b780b6e98f/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Program.cs#L21-L27
Host.CreateDefaultBuilder does most of the same magic for you.
...e/fundamentals/host/hosted-services/samples/2.x/BackgroundTasksSample-GenericHost/Program.cs
Outdated
Show resolved
Hide resolved
I'm currently running in Cloud Foundry using environment variables, so this example is good for that situation. I'll change the prefix to ASPNETCORE |
@mattspicer1 ... Just drop the prefix totally and change |
Env var configuration should flow to the app .... soooo ... finally! lol Strike That should wrap this puppy 🐶 up. [EDIT] Unless @Tratcher you want another override option for env vars there ... in which case ... it would move down in the providers. |
That's fine unless Chris wants to keep it and move it down. It's a minor point tho, so we're probably good to go now. |
This is fine. In 3.0 we'll remove this sample and replace it with a library. |
Excellent! ... I'm in favor of one LESS sample here. 😄 Thanks for the submission @mattspicer1! 🚀 🚀 |
…ConfigureAppConfiguration. ConfigureHostConfiguration must be called first
I've tested this locally. The original code would always use production as the hosted environment.