Azure Monitor OpenTelemetry Profiler for .NET
July 23, 2026 · View on GitHub
Description
The Azure Monitor OpenTelemetry Profiler captures detailed performance traces of your live .NET applications with minimal overhead. It helps you find slow code paths, high-CPU methods, and bottlenecks, then surfaces fixes through Code Optimizations in Application Insights. The profiler runs on a schedule (random sampling) and can also trigger on high CPU or memory.
Learn more: optix — Code Optimizations skills for Copilot · Profiler Agent Selection Guide · CPU & Memory usage monitoring
Get Started
Using this profiler is two phases: enable it (once), then analyze the traces it collects (ongoing). Enabling takes three steps.
Before you begin
You'll need:
- .NET 8.0 or later
- An Application Insights resource
- Its connection string set as the
APPLICATIONINSIGHTS_CONNECTION_STRINGenvironment variable
Step 1 — Add the profiler package
🚀 On Azure App Service (Windows)? You can skip the package reference and code change entirely — see Codeless enablement below.
dotnet add package Azure.Monitor.OpenTelemetry.Profiler --prerelease
Step 2 — Enable the profiler in one line
Find the row that matches the telemetry SDK you already use, and add the highlighted call where you configure telemetry:
| Your SDK | Add this call | Detailed walkthrough |
|---|---|---|
Application Insights SDK for ASP.NET Core (Microsoft.ApplicationInsights.AspNetCore) | AddApplicationInsightsTelemetry().AddAzureMonitorProfiler(); | Option A |
Azure Monitor OpenTelemetry distro (Azure.Monitor.OpenTelemetry.AspNetCore) | AddOpenTelemetry().UseAzureMonitor().AddAzureMonitorProfiler(); | Option B |
| Application Insights SDK for ASP.NET Core — classic 2.x (legacy) | Not supported — use Application Insights Profiler for ASP.NET Core instead | — |
Step 3 — Run your app
dotnet run
Profiler traces appear in Application Insights after a few minutes. How to view them →
🤖 Prefer zero config? Let optix enable it for you. Install the Code Optimizations skills for Copilot CLI and run:
copilot "Help me enable the Application Insights Profiler"
Next: once traces are flowing, analyze them with optix to turn bottlenecks into concrete code fixes. Need more detail on enabling? Expand the walkthrough for your SDK below.
Option A: Application Insights SDK for ASP.NET Core (Experimental)
⚠️ Experimental — This integration is under active development. Please report any issues you encounter.
The current Microsoft.ApplicationInsights.AspNetCore SDK is an OpenTelemetry-based wrapper. Since it already configures OpenTelemetry internally, you can enable the profiler without adding Azure.Monitor.OpenTelemetry.AspNetCore or calling UseAzureMonitor().
Show setup walkthrough
Prerequisites
In addition to the Get Started prerequisites: your project must reference the current OpenTelemetry-based Microsoft.ApplicationInsights.AspNetCore SDK. The legacy classic 2.x release is not supported by this profiler — use Microsoft Application Insights Profiler for ASP.NET Core instead.
Walkthrough
-
Add NuGet Packages
dotnet add package Microsoft.ApplicationInsights.AspNetCore --version "3.*-*" dotnet add package Azure.Monitor.OpenTelemetry.Profiler --prereleaseOr in your
.csproj:<ItemGroup> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="[3.*-*, 4.0.0)" /> <PackageReference Include="Azure.Monitor.OpenTelemetry.Profiler" Version="[1.*-*, 2.0.0)" /> </ItemGroup> -
Enable the Profiler
Chain
AddAzureMonitorProfiler()afterAddApplicationInsightsTelemetry():using Azure.Monitor.OpenTelemetry.Profiler; var builder = WebApplication.CreateBuilder(args); builder.Services.AddApplicationInsightsTelemetry().AddAzureMonitorProfiler(); var app = builder.Build(); app.Run(); -
Set up the connection string
Refer to the connection string section for all options. For local testing in PowerShell:
$env:APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=5d..." -
Run & Verify
dotnet runLook for profiler startup log messages like:
info: Azure.Monitor.OpenTelemetry.Profiler.ServiceProfilerAgentBootstrap[0] Starting application insights profiler with connection string: InstrumentationKey=5d…After a few minutes, traces will appear in Application Insights — see how to view profiler data.
📖 Full example: aspnetcore-aisdk3
Option B: Azure Monitor OpenTelemetry Distro
Show setup walkthrough
Prerequisites
In addition to the Get Started prerequisites: this profiler works with the Azure Monitor OpenTelemetry distro.
Walkthrough
Assuming you are building an ASP.NET Core application:
-
Create a .NET Application (skip if you have one already)
dotnet new web -
Add NuGet Packages
dotnet add package Azure.Monitor.OpenTelemetry.AspNetCore --prerelease dotnet add package Azure.Monitor.OpenTelemetry.Profiler --prereleaseTip: use floating versions to stay on the latest package:
<ItemGroup> <PackageReference Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="[1.*-*, 2.0.0)" /> <PackageReference Include="Azure.Monitor.OpenTelemetry.Profiler" Version="[1.*-*, 2.0.0)" /> </ItemGroup> -
Enable Application Insights with OpenTelemetry
Follow the instructions to enable Azure Monitor OpenTelemetry for .NET, then verify that data is flowing.
-
Enable Profiler
Append the call to
AddAzureMonitorProfiler()in your code:using Azure.Monitor.OpenTelemetry.AspNetCore; // Import the Azure.Monitor.OpenTelemetry.Profiler namespace. using Azure.Monitor.OpenTelemetry.Profiler; ... builder.Services.AddOpenTelemetry() .UseAzureMonitor() .AddAzureMonitorProfiler(); // Add Azure Monitor Profiler ... -
Run Your Application
Run your application and verify the profiler starts. Look for this in the log output:
info: Azure.Monitor.OpenTelemetry.Profiler.ServiceProfilerAgentBootstrap[0] Starting application insights profiler with connection string: InstrumentationKey=5d… info: Azure.Monitor.OpenTelemetry.Profiler.Core.DumbTraceControl[0] Start writing trace file C:\Users\aaa\AppData\Local\Temp\SPTraces\... -
View Profiler Data
After a few minutes, profiler traces will appear in Application Insights. Follow these instructions to view them.

📖 Full example: aspnetcore-webapi
Codeless enablement (no code change) — Beta
Running on Azure App Service? You can enable the profiler without changing your app's code, adding a NuGet package, or recompiling. A Kudu/SCM Site Extension (Windows) injects an ASP.NET Core IHostingStartup at process start, detects your app's telemetry stack (OpenTelemetry or classic Application Insights), and enables the matching profiler automatically. Enablement is fail-safe — if anything is incompatible, the profiler disables itself and your app keeps running.
All you need is an APPLICATIONINSIGHTS_CONNECTION_STRING app setting and a supported .NET telemetry stack.
Analyze Performance with optix
Enabling the profiler is a one-time step. The real, ongoing value is analysis — turning collected traces into fixes. optix (Code Optimizations skills for Copilot) automates that end to end:
- Ingest — finds recent profiler traces on your Application Insights resource and downloads one.
- Identify — extracts the hot path and ranks the top CPU and latency contributors.
- Correlate — links hot frames to a specific operation or distributed trace, plus related errors and failed dependencies.
- Recommend — maps hot frames to your source code and proposes concrete changes.
- Verify — re-profiles after your change to confirm the bottleneck is gone.
Install the Code Optimizations skills for Copilot CLI, then ask:
copilot "Analyze my Application Insights Profiler traces and show me the top CPU bottlenecks"
No profiler data yet? optix will guide you back to enabling the profiler.
Next
- Analyze performance with optix (Copilot CLI)
- Enable the Profiler with optix (Copilot CLI)
- Profiling Azure Service Bus Applications
- Setup the Role name
- Enable the Profiler codelessly (site extension)
- Configuration Guide
- CPU Usage Monitoring
- Memory Usage Monitoring
- Read the examples
Troubleshooting
If profiles are not appearing in Application Insights:
- Check logs — Enable debug logging to see the profiler pipeline activity:
{ "Logging": { "LogLevel": { "Microsoft.ServiceProfiler": "Debug", "Microsoft.ApplicationInsights.Profiler": "Debug" } } } - Verify connection string — Ensure your Application Insights connection string is configured correctly.
- Check triggers — If using CPU or memory triggers, verify your thresholds are below observed usage levels. See CPU Usage Monitoring and Memory Usage Monitoring.
- Entra authentication — If your Application Insights resource requires Entra (AAD) authentication, configure credentials accordingly. The profiler will log an error if authentication is missing.
If you're still experiencing issues, please open an issue with your environment details and relevant log output.
Examples
Learn more by following the examples:
- Application Insights SDK for ASP.NET Core + Profiler — for Option A
- Azure Monitor OpenTelemetry Distro + Profiler (ASP.NET Core WebAPI) — for Option B
Build Status
| Pipeline | Status |
|---|---|
| Package | |
| PR Build | |
| Official Build |
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Data Collection
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.