Conversation
|
How's this coming? Waiting on me for anything? |
|
@ardalis sorry, last week got a little crazy. I'm not sure what you want for the last bullet point if you want to tackle that? Or Slack me some more info and I can try to knock it out today. The rest of it is ready for review though. |
| @@ -0,0 +1,153 @@ | |||
| # Configuring Different Environments | |||
| by [Eric Fleming](https://ericflemingblog.wordpress.com) | |||
There was a problem hiding this comment.
Point this at http://deviq.com/me/eric-fleming/ which we can update however you want.
| In ASP.NET Core controlling application behavior across multiple environments, such as developement, staging, and production, has been improved through the expanded use of environment variables. Environment variables are used to indicate which environment the application is running in, and can be detected programmatically allowing the application to be configured appropriately. | ||
|
|
||
| ## Environment Based Settings Files | ||
| The constructor of the Startup class, found below, provides the ability to use more than one appsettings.json file by leveraging these environment variables. Since the `appsettings` configurations are [read in the order they are specified](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration), the general `appsettings` configuration will be loaded first, followed by an environment specific `appsettings` configuration. |
There was a problem hiding this comment.
It's not clear what impact the order in which they're loaded has. Update to make clear that the "last setting loaded" wins if a setting exists in multiple places. You can look at the docs for an example of how to phrase this, or come up with something that works for you.
| .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) | ||
| ``` | ||
|
|
||
| where `{env.EnvironmentName}` corresponds to the environment variable `ASPNETCORE_ENVIRONMENT`. When using Visual Studio, the value for the `ASPNETCORE_ENVIRONMENT` variable can be found in your project's debug profiles show below: |
There was a problem hiding this comment.
"corresponds to the value of the environment variable"
|
|
||
| and should be set to `Development` by default. | ||
|
|
||
| Environment variables will be updated throughout the environments; for example, on Staging the environment variable will likely be set to `Staging`, and for production it will likely be set to `Production`. |
There was a problem hiding this comment.
Not sure what this is saying. "will be updated" by whom?
Is this meant to be saying they can be configured for each environment in which the application may be deployed?
| Setting the current environment for macOS can be done in-line when running the application; | ||
|
|
||
| ```bash | ||
| ASPNETCORE_ENVIRONMENT=Development dotnet run |
There was a problem hiding this comment.
This is neat; didn't realize you could do this.
|
|
||
| Machine level environment variables are set in the .bashrc or .bash_profile file. Edit the file using any text editor and add the following statment. | ||
|
|
||
| ```powershell |
There was a problem hiding this comment.
why are you formatting this as powershell?
There was a problem hiding this comment.
I wasn't sure what else to format it as :)
|
|
||
| #### Command Line | ||
| ```powershell | ||
| setx ASPNETCORE_ENVIRONMENT "Development" |
There was a problem hiding this comment.
setx? what about set? Is setx different? I've always used just set.
There was a problem hiding this comment.
I've always thought set took effect in the local shell you have but you would lose the environment variable once you close the prompt.
Setx on the other hand makes the change permanent but you'll have to open a new shell to see the change take place.
|
LMK when you think you can get to the changes requested. I'd like to merge this PR and then make a separate one to add the last bullet's info. |
|
@ardalis I've addressed all but 1 comment. Just let me know which you would rather me use. |
Still working on the last bullet, but wouldn't hurt to get eyes on this sooner rather than later.