| Continuous Integration | Status |
|---|---|
| Package | |
| PR Build | |
| Official Build |
The Azure Monitor OpenTelemetry Profiler captures detailed performance traces of your live .NET applications with minimal overhead. It helps you identify slow code paths, high-CPU methods, and performance bottlenecks — then surfaces actionable insights through Code Optimizations in your Application Insights resource.
The profiler supports both random sampling (periodic snapshots) and trigger-based profiling (activated when CPU or memory usage exceeds a threshold). See CPU Usage Monitoring and Memory Usage Monitoring for details on triggered profiling.
⭐ Not sure which
Profiler Agentis right for you? Check out our Profiler Agent Selection Guide to help you choose the best option for your needs.
Choose the path that matches your project:
| SDK | Path |
|---|---|
Azure Monitor OpenTelemetry distro (Azure.Monitor.OpenTelemetry.AspNetCore) |
Option A |
Application Insights ASP.NET Core 3.x (Microsoft.ApplicationInsights.AspNetCore 3.x) |
Option B |
| Application Insights ASP.NET Core 2.x (classic SDK) | Use Microsoft Application Insights Profiler for ASP.NET Core instead |
- .NET 8.0 or later: Install the latest .NET SDK from here.
- Application Insights Resource: Follow this guide to create a new Application Insights resource.
- Azure Monitor OpenTelemetry: This profiler works with the Azure Monitor OpenTelemetry distro.
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 --prerelease
Tip: 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:
PS > dotnet run Building... info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:5143 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development info: Microsoft.Hosting.Lifetime[0] Content root path: C:\ 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
⚠️ Experimental — This integration is under active development. Please report any issues you encounter.
Microsoft.ApplicationInsights.AspNetCore 3.x 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().
- .NET 8.0 or later: Install the latest .NET SDK from here.
- Application Insights Resource: Follow this guide to create a new Application Insights resource.
- Application Insights ASP.NET Core 3.x: Your project must reference
Microsoft.ApplicationInsights.AspNetCoreversion 3.x or later.
-
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
The code differs slightly depending on which version of
Azure.Monitor.OpenTelemetry.Profileryou are using:Azure.Monitor.OpenTelemetry.Profiler1.0.0-beta10 and later — a single fluent chain:using Azure.Monitor.OpenTelemetry.Profiler; var builder = WebApplication.CreateBuilder(args); builder.Services.AddApplicationInsightsTelemetry().AddAzureMonitorProfiler(); var app = builder.Build(); app.Run();
Azure.Monitor.OpenTelemetry.Profiler1.0.0-beta9 and earlier — separate calls:using Azure.Monitor.OpenTelemetry.Profiler; var builder = WebApplication.CreateBuilder(args); builder.Services.AddApplicationInsightsTelemetry(); builder.Services.AddOpenTelemetry().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 run
Look 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
As an alternative to the manual walkthrough above, you can use Copilot to enable the profiler automatically (works for both Option A and Option B):
- Setup the Role name
- Configuration Guide
- CPU Usage Monitoring
- Memory Usage Monitoring
- Read the examples
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.
Learn more by following the examples:
- Azure Monitor OpenTelemetry Distro + Profiler (ASP.NET Core WebAPI) — for Option A
- Application Insights ASP.NET Core 3.x + Profiler — for Option B
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.
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.
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.
