Skip to content

Enable with Azure Monitor OpenTelemetry Distro

Saar Shen edited this page Aug 13, 2026 · 1 revision

Enable the profiler with the Azure Monitor OpenTelemetry distro

This is the most common setup: you already call UseAzureMonitor() from the Azure Monitor OpenTelemetry distro (Azure.Monitor.OpenTelemetry.AspNetCore), and you want to add the profiler to it.

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:

  1. Create a .NET Application (skip if you have one already)

    dotnet new web
  2. 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>
  3. Enable Application Insights with OpenTelemetry

    Follow the instructions to enable Azure Monitor OpenTelemetry for .NET, then verify that data is flowing.

  4. 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
    ...
  5. 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\...
  6. View Profiler Data

    After a few minutes, profiler traces will appear in Application Insights. Follow these instructions to view them.

📖 Full example: aspnetcore-webapi

See also

Clone this wiki locally