Hello @Knut Wannheden I believe you want to create the dependency with the legacy id : https://github.com/microsoft/ApplicationInsights-Announcements/issues/27
For correlation headers : https://learn.microsoft.com/en-us/azure/azure-monitor/app/correlation#correlation-headers-using-w3c-tracecontext
-----------------------------------------------------------------------------------------------------------
UPDATE :
The feature is automatic - developer should not need to do anything for http interactions as this is handled by the App Insights SDK.
For example:
(1) I deploy a http function with app insights resource
(2) I deploy APIM and add App Insights via the ikey to APIM (this could be the same resource as the function, or i could create a new App Insights resource for APIM)
(3) I add the function as a new API to APIM and configure the API (in settings) to point to my APIM App Insights resource
(4) Trigger APIM API via the Azure Portal "test" page
(5) observe in App Insights after a minute or so
Note: It's important to send more than one request - ideally for at least 1 min to allow App Insights to correlate correctly.
[Function-call correctly correlated without writing any extra code]
The reason this works is because Function looks at the W3C context and in this case (as it's a dot net/c# function) sets the activity id for the thread running the function request. By the time the function code runs the telemetry has already been correlated and any further actions (for example a downstream depend to the function) would also correlate correct. The same should apply when using App Insights SDK with any app listening on http endpoint.
More work is required wherein there's a storage queue, or event grid or any service between resources that doesn't "see app insights" (e.g. does not support flowing the correlation information).
References:
https://learn.microsoft.com/en-us/azure/azure-monitor/app/custom-operations-tracking#azure-storage-queue ( this is an example of the "exception" - where it is not possible to automatically propagate the necessary values and additional work is required. For http => http this should be automatic via the AI SDK)
Another one which might help in this case : https://tsuyoshiushio.medium.com/correlation-with-activity-with-application-insights-3-w3c-tracecontext-d9fb143c0ce2