I use the system variables on the Windows server.
Windows - Set environment variable globally
See the official documentation for all the different ways to handle configuration in ASP.NET Core.
Configuration in ASP.NET Core
Setting ASPNETCORE_ENVIRONMENT variables system wide for BLUE GREEN setup
Hi,
we have a number of environments (CI, QA, STAGING, BLUE, GREEN) where we have set the ASPNETCORE_ENVIRONMENT variable for the entire environment at the machine level.
this is set in the applicationHost.config in the system.webServer area as shown below.
<aspNetCore>
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="DEV" />
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="DEV" lockItem="true" />
</environmentVariables>
</aspNetCore>
However in our BLUE GREEN environments, a set of webservers might be for TEST and then another is PRODUCTION and vice versa.
I know we can do this in the web.configs for each app but was hoping we can do this machine wide like we did above.
is there a way to set these values programatically for the entire webserver? Thanks in advance
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="RC" />
<envi
3 answers
Sort by: Most helpful
-
AgaveJoe 28,366 Reputation points
2023-04-18T22:04:46.99+00:00 -
TengFeiXie-MSFT 346 Reputation points
2023-04-19T07:58:53.0866667+00:00 Hi, @Lance Lyons
To set the value globally in Windows, use either of the following approaches: Open the Control Panel > System > Advanced system settings and add or edit the
ASPNETCORE_ENVIRONMENT
value:Of course, you can also set environment variables in the applicationhost.config of IIS, which will take effect on the application you deploy in IIS. Just like this link, But sometimes it still need to set it in web.config.
Best Regard,
TengFei Xie
If the answer is the right solution, please click "Accept Answer" and kindly upvote. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
-
jacqueline callaghan 0 Reputation points
2024-03-17T09:57:16.2966667+00:00 How do I delete this