When I use azure module (to query Service Bus) and Application Insights module, I get the following error upon initialization of AppsInsight:
System.Exception : Error: Zone already loaded. at new Error (native) at Error.AppInsightsAsyncCorrelatedErrorWrapper
The code to replicate it is very simple:
var azure = require('azure');
var serviceBusService = azure.createServiceBusService(<Service Bus Endpoint>);
const appInsights = require("applicationinsights");
appInsights.setup(<Apps Insight key>).start();
The error is thrown on the last line and I assume is a result of dependencies overlapping between azure and applicationinsights module.
Any suggestions how to overcome this are appreciated!
According to your description, I created my JavaScript HttpTrigger function to check this issue. I used applicationinsights (version 0.22.0) and I could reproduce this issue as follows:
package.json:
Then I checked the applicationinsights package and call
appInsights.setAutoDependencyCorrelation(false)
, then it could work as expected as follows: