Reputation: 852
I have been following this article for adding cloud_RoleName to my web-app (https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/azure-monitor/app/app-map.md#net), I just tried this with a very simple ASP.net web-app. I created a class library for telemetry and referenced it with my Web-App and made sure Instrumentation Key is used. Now when I initialize the custom TELEMETRY class programmatically i.e. (Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.TelemetryInitializers.Add(new ExtendedIDTelemetryInitializer())) .. It works very well and no issues at all. Telemetry gets sent to my Azure App Insights Resource with my custom CLOUD_ROLENAME but samething if I try to add it declaratively i.e. adding the INITIALIZE code to ApplicationInsights.config file, it DOESNT WORK :( nothing is reported with my CUSTOM cloud_RoleName to Azure App insights, any help with this? I want to go the DECLARATIVE route instead of programmatic as I need to send this code to a third party product and they cant make changes to the STARTUP event to add it. Not sure why DECLRATIVE is Not working any help? my ApplicationInsights.config file looks like this . Any help?<Add Type="KSTelemetry.Telemetry.MyTelemetryInitializer,KSTelemetry"/>
Upvotes: 0
Views: 726
Reputation: 3196
if you were using asp.net core application, then declarative config via ApplicationInsights.config is not supported. Adding TelemetryInitializers must be done by adding it to the DI container as shown in below link https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core#adding-telemetryinitializers
Upvotes: 2