ApplicationInsights-node.js
ApplicationInsights-node.js copied to clipboard
Local Auth Disabled Issues
Issue
I am using [email protected] in my nodejs application. When I went to disable local authentication I stopped getting telemetry even when supplying the credential. I have tried adding Monitoring Metrics Publisher, Log Analytics Contributor and just Contributor to the user with no change.
Is this still supported in the 3.X SDK?
Code
const appInsights = require('applicationinsights');
const {DefaultAzureCredential} = require('@azure/identity');
appInsights
.setup()
.setInternalLogging(true, true)
.setAutoCollectRequests(true)
.setAutoCollectPerformance(true, true)
.setAutoCollectExceptions(true)
.setAutoCollectDependencies(true)
.setAutoCollectConsole(true)
.setSendLiveMetrics(true)
.start();
const credential = new DefaultAzureCredential();
let client = appInsights.defaultClient;
client.config.aadTokenCredential = credential;
client.trackEvent({name: "my custom event", properties: {customProperty: "custom property value"}});
client.trackException({exception: new Error("handled exceptions can be logged with this method")});
client.trackMetric({name: "customMetric", value: 3});
client.trackTrace({message: "trace message"});
client.trackDependency({target:"http://dbname", name:"select customers proc", data:"SELECT * FROM Customers", duration:231, resultCode:0, success: true, dependencyTypeName: "ZSQL"});
client.trackRequest({name:"GET /customers", url:"http://myserver/customers", duration:309, resultCode:'200', success:true});
client.flush();