Azure Functions with node.js, Azure Service Bus an

2019-07-29 05:58发布

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!

1条回答
Deceive 欺骗
2楼-- · 2019-07-29 06:26

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:

enter image description here

package.json:

{
  "name": "functions-app-insights",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "applicationinsights": "^0.22.0",
    "node-uuid": "^1.4.8"
  }
}

Then I checked the applicationinsights package and call appInsights.setAutoDependencyCorrelation(false), then it could work as expected as follows:

enter image description here

查看更多
登录 后发表回答