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 via three different methods:

  • Visual Studio and Azure Resource Manager
  • PowerShell

Select your preferred method tab to:

In this guide, you learn how to:

  • Configure the Azure Diagnostics extension to run the .NET Profiler.
  • Install the Application Insights SDK on a VM.
  • Deploy your application.
  • View Profiler traces via the Application Insights instance in the Azure portal.

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 > Next.

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

  5. Select where to save the connection string and 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 the Application Insights for ASP.NET Core 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.

  4. Select Update.

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

Enable the .NET Profiler

You can enable Profiler by any of the following two ways:

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

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 instrumentation key to MyApplicationInsightsProfilerSink.

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

Can the .NET Profiler run on on-premises servers?

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

Next steps