I've talked about how to setup Application Insights in an Angular application and also shared how to set the cloud role name in ASP.NET Core to improve the telemetry reporting. Let's build on top of these 2 posts and show you today how to update the cloud role name in an Angular application.
We’ll start by extending our environment.ts
file with an extra configuration setting to store the application name:
Once that is done, we need to go the service (app-insights.service.ts
) where we create our Application Insights instance. There we need to add a custom telemetry initializer by calling the addTelemetryInitializer
method:
Now when we run our Angular application, the cloud role name should be reported correctly to Application Insights.