feat: Add Azure Application Insights integration with OpenTelemetry and .NET Profiler#741
Merged
BenjaminMichaelis merged 7 commits intomainfrom Jun 27, 2025
Merged
feat: Add Azure Application Insights integration with OpenTelemetry and .NET Profiler#741BenjaminMichaelis merged 7 commits intomainfrom
BenjaminMichaelis merged 7 commits intomainfrom
Conversation
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
…ntation Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add azure application insights
Add Azure Application Insights integration with OpenTelemetry and .NET Profiler
Jun 25, 2025
Ensures Azure Application Insights and Service Profiler are only configured in non-development environments to avoid conflicts and resource consumption during local development.
Adds the Application Insights connection string to the container app configuration for both staging and production environments. This allows collecting telemetry data from the application.
Removes the Application Insights tests, which appear unnecessary at this stage. Adds a functional test for the health check endpoint.
BenjaminMichaelis
approved these changes
Jun 27, 2025
BenjaminMichaelis
added a commit
that referenced
this pull request
Apr 25, 2026
…nd .NET Profiler (#741) This PR integrates Azure Application Insights with OpenTelemetry and the .NET Profiler to provide comprehensive monitoring and performance profiling for the ASP.NET Core application. ## Changes Made ### Package Dependencies - Added `Azure.Monitor.OpenTelemetry.AspNetCore` (v1.3.0) for OpenTelemetry integration - Added `Microsoft.ApplicationInsights.Profiler.AspNetCore` (v2.6.0) for .NET Profiler support ### Configuration Updates - **Program.cs**: Added OpenTelemetry configuration with `UseAzureMonitor()` - **Program.cs**: Added Application Insights telemetry services with `AddApplicationInsightsTelemetry()` - **Program.cs**: Added Service Profiler with `AddServiceProfiler()` - **Program.cs**: Added required using statement for `Azure.Monitor.OpenTelemetry.AspNetCore` ### Environment Configuration - The application now automatically reads the `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable - All logs and exceptions are automatically sent to Application Insights - Compatible with containerized deployment using the existing Dockerfile ### Documentation & Testing - **README.md**: Updated with `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable documentation - **README.md**: Updated .NET SDK requirement to 9.0 - **ApplicationInsightsTests.cs**: Added basic integration tests to verify Application Insights services are properly registered ## Runtime Configuration Set the following environment variable to enable Application Insights: ```bash APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=your-instrumentation-key-here;IngestionEndpoint=https://region.in.applicationinsights.azure.com/;LiveEndpoint=https://region.livediagnostics.monitor.azure.com/" ``` ## Benefits - **Telemetry**: Automatic collection of requests, dependencies, exceptions, and custom metrics - **Logging**: All application logs are sent to Application Insights - **Profiling**: .NET Profiler provides detailed performance insights - **Monitoring**: OpenTelemetry integration provides distributed tracing - **Container Support**: Works seamlessly in containerized environments This implementation follows Microsoft's best practices from the official documentation for OpenTelemetry and Application Insights integration. Fixes #740. > [!WARNING] > > <details> > <summary>Firewall rules blocked me from connecting to one or more addresses</summary> > > #### I tried to connect to the following addresses, but was blocked by firewall rules: > > - `download.visualstudio.microsoft.com` > - Triggering command: `wget REDACTED -O dotnet-sdk.tar.gz ` (dns block) > > If you need me to access, download, or install something from one of these locations, you can either: > > - Configure [Actions setup steps](https://gh.io/copilot/actions-setup-steps) to set up my environment, which run before the firewall is enabled > - Add the appropriate URLs or hosts to my [firewall allow list](https://gh.io/copilot/firewall-config) > > </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to start the survey. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com> Co-authored-by: Benjamin Michaelis <git@relay.benjamin.michaelis.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR integrates Azure Application Insights with OpenTelemetry and the .NET Profiler to provide comprehensive monitoring and performance profiling for the ASP.NET Core application.
Changes Made
Package Dependencies
Azure.Monitor.OpenTelemetry.AspNetCore(v1.3.0) for OpenTelemetry integrationMicrosoft.ApplicationInsights.Profiler.AspNetCore(v2.6.0) for .NET Profiler supportConfiguration Updates
UseAzureMonitor()AddApplicationInsightsTelemetry()AddServiceProfiler()Azure.Monitor.OpenTelemetry.AspNetCoreEnvironment Configuration
APPLICATIONINSIGHTS_CONNECTION_STRINGenvironment variableDocumentation & Testing
APPLICATIONINSIGHTS_CONNECTION_STRINGenvironment variable documentationRuntime Configuration
Set the following environment variable to enable Application Insights:
APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=your-instrumentation-key-here;IngestionEndpoint=https://region.in.applicationinsights.azure.com/;LiveEndpoint=https://region.livediagnostics.monitor.azure.com/"Benefits
This implementation follows Microsoft's best practices from the official documentation for OpenTelemetry and Application Insights integration.
Fixes #740.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
download.visualstudio.microsoft.comwget REDACTED -O dotnet-sdk.tar.gz(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.