Blog Post

Azure Integration Services Blog
2 MIN READ

Application Insights for Azure Logic Apps (Standard) - Correlation Tracking Update

KentWeareMSFT's avatar
KentWeareMSFT
Icon for Microsoft rankMicrosoft
May 06, 2024

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 (microsoft.com)

 

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

 

 

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

 

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.

 

 

 

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.

 

 

 

 

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.

 

 

This will allow the Application Map to render properly.

 

 

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:

 

 

 

 

 

Updated May 06, 2024
Version 1.0
No CommentsBe the first to comment