Differentiate code running in production and staging slots

205 Views Asked by At

I have an Azure Function which has 2 slots: production and staging slots. Both slots have same values for all the config settings. For example, both slots send logs to the same log analytics workspace. Is there a way to differentiate the logs coming from staging and production slots? For example - add a prefix 'staging' for all the logs coming from staging slot?

enter image description here

1

There are 1 best solutions below

0
On

Yes! You can differentiate the logs came from two different slots like Production and Staging Slot.

I have created the .NET 6 Function App with 1 HTTP Trigger and 1 Timer Trigger published to both Production & Staging Deployment Slots.

Production Slot Logs:

enter image description here

Staging Slot Function Logs:

enter image description here

Here the Role name having 2 values:

  • krishfuncnet6app01
  • krishfuncnet6app01-staging

By default, the App Insights SDK set the cloud role name for you as the Azure App service Name which means the name of the Web App/Function App.

You can also set the custom Role Name to identify easily if you have multiple deployment slots, refer here for more information on a practical workaround of setting up the custom cloud role name using TelemetryInitializer class.