问题
I would like to set the cloud_rolename of the telemetry sent from my Azure Function App (v2) that is sent to application insights.
The AI configuration in my host.json looks like this:
"applicationInsights": {
"sampling": {
"isEnabled": true,
"maxTelemetryItemsPerSecond" : 1
}
}
I have been unable to find any documentation on where to set cloud rolename in function apps. How should I go about this?
回答1:
You should be able to do this by registering a custom TelemetryInitializer
. See here: https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/759#issuecomment-426687852.
We currently set that role name in an initializer today here: https://github.com/Azure/azure-webjobs-sdk/blob/dev/src/Microsoft.Azure.WebJobs.Logging.ApplicationInsights/Initializers/WebJobsRoleEnvironmentTelmetryInitializer.cs.
Can I ask what your scenario is that you'd want to override it?
来源:https://stackoverflow.com/questions/53042476/configure-cloud-role-name-for-application-insights-in-an-azure-function-app