Azure App Insights broken when using ServiceDefaults #4687
-
Well #4322 was closed, but I still have an issue with app insights not pushing in my app when running on Azure. I added Orchestrator support to my app and all seemed great. But when running on Azure App Services, I noticed app insights were no longer pushing.
The issue seems to stem from the call to
in the ServiceDefaults. If i comment that out and run in Azure, my insights start working again. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
cc @samsp-msft |
Beta Was this translation helpful? Give feedback.
-
It looks like you are mixing the classic Application Insights SDK and OpenTelemetry. Aspire is built using OpenTelemetry and the OTel based exporters to AzureMonitor/Application Insights. The call to ServiceDefaults is setting up OpenTelemetry. To use Application Insights with Aspire, please use either Azure Monitor Distro or Azure monitor exporter. The former is a wrapper around the latter that provides good defaults and extensions to provide the best experience. https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=aspnetcore#enable-azure-monitor-opentelemetry-for-net-nodejs-python-and-java-applications |
Beta Was this translation helpful? Give feedback.
-
Ok, I will look into those thanks. The issue in my opinion here is adding App Insights telemetry to the project via right click gives you this code. Adding Aspire orchestration which then adds the Service defaults gives you conflicting code. Something to consider ;) |
Beta Was this translation helpful? Give feedback.
-
Is there a use case in this scenario where you would want to use AddApplicationInsightsTelemetry when deployed to azure, but ConfigureOpenTelemetry when running locally. Thinking mainly about when existing services which already use AppInsights have Aspire support added to them, and a developer might want to use OTEL and the Aspire Dashboard when running locally, but retain the existing AppInsights when deployed (via whatever existing deployment mechanism the service already has in place) |
Beta Was this translation helpful? Give feedback.
It looks like you are mixing the classic Application Insights SDK and OpenTelemetry. Aspire is built using OpenTelemetry and the OTel based exporters to AzureMonitor/Application Insights. The call to ServiceDefaults is setting up OpenTelemetry.
To use Application Insights with Aspire, please use either Azure Monitor Distro or Azure monitor exporter. The former is a wrapper around the latter that provides good defaults and extensions to provide the best experience.
https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=aspnetcore#enable-azure-monitor-opentelemetry-for-net-nodejs-python-and-java-applications
https://learn.microsoft.com/en-us/dotnet/aspire/deploy…