This sample demonstrates how to create a Business Activity Monitoring (BAM) transaction view that correlates events from two separate Application Insights instances. In this scenario, a third-party application submits reservations to a booking API exposed via Azure API Management (APIM), which routes requests to Azure Functions for backend processing. BAM combines telemetry from both services into a single consolidated transaction view for support and business users.
In this example, stages are sourced from the APIM backend and from request and trace log events in Azure Functions. You can extend this scenario using custom log events in your functions.
Walkthrough video
Overview
Business value
This sample shows how BAM data queries can unify telemetry from multiple Azure services into a single transaction view. Support operators and business users can trace a booking request from its APIM entry point through to function execution — without requiring access to Application Insights or developer assistance.
How it works
The parent transaction query filters the APIM request log in Application Insights for a specific API operation and returns one row per booking request. Stage queries then correlate on operation_Id to retrieve the APIM backend dependency event and the corresponding function request and trace events from a separate Application Insights instance.
Parent transaction query
This query retrieves requests for the booking-save API operation from APIM. The operation_Id field is used to correlate each parent record with its downstream stage events.
let inputApimServiceName = "kv-eai-apim.azure-api.net";
let inputApiName = "external-api-booking-api";
let inputOperationName = "booking-save";
requests
| where customDimensions.["Service Name"] == inputApimServiceName
| where customDimensions.["API Name"] == inputApiName
| where customDimensions.["Operation Name"] == inputOperationName
| order by timestamp desc
Stage queries
API backend stage
This stage retrieves the APIM backend dependency call for the booking request. It correlates with the parent transaction using operation_Id.
let inputOperationId = {operation_Id};
let inputApimServiceName = "kv-eai-apim.azure-api.net";
let inputApiName = "external-api-booking-api";
let inputOperationName = "PUT /api/Booking-Save";
dependencies
| where type == "Backend"
| where customDimensions.["Service Name"] == "kv-eai-apim.azure-api.net"
| where operation_Id == inputOperationId
| where name == inputOperationName
Function request stage
This stage retrieves the Azure Functions request log event for the booking execution. It correlates with the parent transaction using operation_Id.
let inputOperationId = {operation_Id};
let inputFunctionAppName = "kv-res-booking-api";
let inputFunctionName = "Booking-Save";
requests
| where cloud_RoleName == inputFunctionAppName
| where name == inputFunctionName
| where operation_Id == inputOperationId
Function trace stage
This stage retrieves the function trace log event that confirms the function started. It correlates with the parent transaction using operation_Id.
let inputOperationId = {operation_Id};
let inputFunctionAppName = "kv-res-booking-api";
let inputFunctionName = "Functions.Booking-Save";
traces
| where operation_Id == inputOperationId
| where cloud_RoleName == inputFunctionAppName
| where customDimensions.prop__functionName == inputFunctionName
| extend prop__status_ = tostring(customDimensions.prop__status)
| where customDimensions.EventName == "FunctionStarted"