0

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.

Kea501
  • 63
  • 3
  • 11

1 Answers1

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.

enter image description here

Please refer MS Doc and SO Thread for more information

Harshitha Veeramalla
  • 1,515
  • 2
  • 10
  • 11