Enable the .NET Profiler for web apps on an Azure virtual machine

Note

We recommend that you use the Azure Az PowerShell module to interact with Azure. To get started, see Install Azure PowerShell. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.

In this article, you learn how to run Application Insights Profiler for .NET on your Azure virtual machine (VM) or Azure virtual machine scale set by using three different methods:

  • Visual Studio and Azure Resource Manager
  • PowerShell

Select your preferred method tab to:

In this guide, you learn how to:

  • Add the Application Insights SDK to your application.
  • Confirm the latest stable release of the Application Insights SDK.
  • Enable the .NET Profiler.

Note

Currently, Application Insights Profiler for .NET isn't supported for on-premises servers.

Prerequisites

Add the Application Insights SDK to your application

  1. Open your ASP.NET core project in Visual Studio.

  2. Select Project > Add Application Insights Telemetry.

  3. Select Azure Application Insights, then select Next.

  4. Select the subscription where your Application Insights resource lives, then select Next.

  5. Select where to save the connection string, then select Next.

  6. Select Finish.

Note

For full instructions, including how to enable Application Insights on your ASP.NET Core application without Visual Studio, see Monitor .NET and Node.js applications.

Confirm the latest stable release of the Application Insights SDK

  1. Go to Project > Manage NuGet Packages.

  2. Select Microsoft.ApplicationInsights.AspNetCore.

  3. On the side pane, select the latest version of the SDK from the dropdown list.

  4. Select Update.

    Screenshot that shows where to select the Application Insights package for update.

Enable the .NET Profiler

You can enable Profiler in these ways:

  • Within your ASP.NET Core application by using an Azure Resource Manager template and Visual Studio. Recommended.
  • By using a PowerShell command.

Install the Azure Diagnostics extension

  1. Choose which ARM template to use:

  2. In the template, locate the resource of type extension.

  3. In Visual Studio, go to the arm.json file in your ASP.NET Core application that was added when you installed the Application Insights SDK.

  4. Add the resource type extension from the template to the arm.json file to set up a VM or virtual machine scale set with Azure Diagnostics.

  5. Within the WadCfg tag, add your Application Insights connection string to MyApplicationInsightsProfilerSink.

    "WadCfg": {
      "SinksConfig": {
        "Sink": [
          {
            "name": "MyApplicationInsightsProfilerSink",
            "ApplicationInsightsProfiler": "YOUR_APPLICATION_INSIGHTS_INSTRUMENTATION_KEY"
          }
        ]
      }
    }        
    
  6. Deploy your application.

Next step