Application Insights for Azure Logic Apps (Standard) - Correlation Tracking Update
Published May 06 2024 01:27 PM 1,263 Views
Microsoft

In this blog post we are going to discuss a new feature flag that will modify the default behavior of passing correlation between Azure services and Logic Apps when tracking data using Application Insights v2. The feature allows you to control the Operation Id that gets emitted to Application Insights V2. The default behavior is to store the workflow's Run Id in the operation_id field. The impact of this default behavior is that it can lead to additional complexity when trying to correlate events across other services like API Management and Azure Functions.

 

Note: To learn more about Application Insights (V2), please check out the following blog post: Application Insights Enhancements for Azure Logic Apps (Standard) reaches General Availability (micr...

 

The following image depicts the default behavior when an API subsequently calls a Logic App workflow which subsequently calls a Function App.

 

KentWeareMSFT_0-1715007513999.png

 

If you subsequently try to view the Application Map in Application Insights, you will see that the correlation is disconnected.

 

KentWeareMSFT_0-1715007644594.png

To address the need of propagating correlation values and creating linkages, we have enabled a feature flag that will allow you to override the default behavior and instead use an operation_id of the calling service. The following image illustrates the desired outcome that we are interested in. The remainder of this post will be dedicated to setting this up correctly.

KentWeareMSFT_0-1715006435194.png

 

 

 

To ensure that the correlation between Azure API Management and Azure Logic Apps lines up correctly, it is advisable to enable the W3C Correlation protocol in the API Management - API.

 

KentWeareMSFT_0-1715006766462.png

 

 

 

You will also need to enable the "Runtime.ApplicationInsights.PreserveIncomingOperationId": "true" in the host.json file of your Logic App. You can enable this in VS Code or by using Kudu in Azure Portal. Save these new settings and make sure that your Logic App is restarted. This feature flag is disabled by default, meaning if you don't enable it, your logging will use the default behavior as above. 

 

Note: In the configuration below, we have set  "Runtime.ApplicationInsightTelemetryVersion": "v2". This enables v2 of our Application Insights functionality. If you do not have v2 enabled, there is no need to set he PreserveIncomingOperationId as this is only available in v2.

 

 

 

 

 

{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows",
    "version": " [1, 2.00) "
  },
  "extensions": {
    "workflow": {
      "Settings": {
        "Runtime.ApplicationInsightTelemetryVersion": "v2",
        "Runtime.ApplicationInsights.PreserveIncomingOperationId": "true"
      }
    }
  }
}

 

 

 

 

When we rerun our transaction using the new feature flag, we can see that we have a consistent operation_id across our API, workflows and Function App.

 

KentWeareMSFT_0-1715018586411.png

 

This will allow the Application Map to render properly.

 

KentWeareMSFT_0-1715021635946.png

 

If you are using Application Insights v2 in Azure Logic Apps, it is recommended that you enable this feature so that you don't have breakages in the Application Map functionality. However, this setting is opt-in so that we don't impact any existing deployments of Logic Apps and Application Insights logging.

 

Looking for a video on this content? Check out the following YouTube video:

 

 

 

 

 

Co-Authors
Version history
Last update:
‎May 06 2024 01:27 PM
Updated by: