Quick question. How can I get the name of the azure environment name (Production/Staging/QA) at run time in .net core? I tried System.Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") and System.Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT"). The first ASPNETCORE_ENVIRONMENT only returns the environment when it runs locally.
Asked
Active
Viewed 131 times
-1
-
Why do you need it? What are you trying to do differently when on prod/staging/QA environment? – Anand Sowmithiran Apr 03 '22 at 17:04
-
1WEBSITE_SLOT_NAME environment variable will indicate the deployment `slot`, it may help you. Depends on how you manage your dev/QA environments. – Anand Sowmithiran Apr 03 '22 at 17:16
1 Answers
1
- Use the below line of code to get the Environment name in Azure
var slot = System.Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", EnvironmentVariableTarget.Process);
- Add the Application settings in Configuration section of your Web App.
HarshithaVeeramalla-MT
- 3,013
- 2
- 2
- 9
-
Hey @Kea501 ! had it solved your problem else you can share more details so I can troubleshoot? – HarshithaVeeramalla-MT May 06 '22 at 08:32