I have an Azure Function app written in javascript that has Application Insights integrated:
const AppInsights = require("applicationinsights");
AppInsights.setup(appInsightsInstrumentationKey);
AppInsights.defaultClient.context.tags[
AppInsights.defaultClient.context.keys.cloudRole
] = "My back-end";
AppInsights.start();
The module version is 1.7.4.
I do need to access the current operation id to send it to my custom log for correlation with AI logs in Azure. In my functions I tried this:
var telemetry = appInsights.defaultClient;
var oid = telemetry.context.tags["ai.operation.id"]; // does not work
var oid = telemetry.context.operation.id; // does not work
Nevertheless, AI collects it somehow so I can see it in Azure portal:
How can I access operation_id
value at run-time in my Azure functions?
You can give it a try with this line of code:
//operation id
var s = client.context.keys["operationId"];
I found it via debug, the screenshot as below:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With