Search code examples
azureazure-application-insights

How to change "AspNetCoreEnvironment: Production" value in Azure Application Insights trace logs?


we are about to migrate classic app insights of all 3 environment(dev, test and prod) to single workspace-based application insights, and noticed in application insights of all 3 environments(dev,test and prod) logs, the value of AspNetCoreEnvironment is production. we dont know based on what and where it is inserting/coming from.

enter image description here

is there any way to change this AspNetCoreEnvironment value by code wise or azure protal side, so we can categized the logs based on the environments.


Solution

  • By default, the value of AspNetCoreEnvironment of the deployed App is Production.

    • You can see the 2 deployment slots here. I have deployed my sample App to Staging and Production.

    • In Application Insights, you can see that even for the staging slot the Environment is shown as Production.

    enter image description here

    • If you want to change the value, it can be done from the Application Setting under Settings => Environment Variables.

    • Add the setting for the particular deployment slot where you want to change the value.

    enter image description here

    Output after changing the value:

    enter image description here