Fully featured low overhead profiler for Java EE and Java SE platforms.
Easy-to-use performance and memory .NET profiler for Windows, Linux and macOS.
Secure and easy profiling in cloud, containers and clustered environments.
Performance monitoring and profiling of Jenkins, Bamboo, TeamCity, Gradle, Maven, Ant and JUnit.

Profile ASP.NET web app on Azure App Service on Linux

This article describes how to set up profiling of ASP.NET web app in a Linux container running on Azure App Service.

YourKit Connection Broker setup

We will use YourKit Connection Broker as a middleware, which helps to establish connection between profiler UI and the profiler agent running on the cloud.

This is a step-by-step instruction how to sign-up YourKit Connection Broker account. All preparations should not take more than 5 minutes. You need to create a security zone and access token to it.

In this example:

  • The connection broker has https://mybroker address. The real broker address you got after signing up with broker account.
  • The access token to the security zone is mytoken. The real token you have just created on the first YourKit Connection Broker setup step.

Download profiler to the container

Select your application in the Azure App Service portal. In the left navigation, select SSH under Development Tools section, and click Go. It will open SSH session in a browser.

SSH in Azure App Service portal

We need the profiler agent to be available in a persistent location. Let's download and unpack it to the /home directory. To do this, type the following commands in the SSH console.

cd /home
wget https://www.yourkit.com/dotnet-profiler/download/docker/YourKit-NetProfiler-2023.9-docker.zip
unzip YourKit-NetProfiler-2023.9-docker.zip

Enable profiling in the Azure portal

In the app's left menu, select Configuration > Application settings.

Azure App Service application settings

To be able to capture snapshots and analyze them after container restarts, we'll set a writeable and persistent snapshot directory /home/snapshots with the startup option dir.

To enable profiling we need to add the following settings. Make sure to enter correct agent path and broker settings.

Name Value
YNP_STARTUP_OPTIONS broker_url=https://mybroker,broker_token=mytoken,dir=/home/snapshots
CORECLR_ENABLE_PROFILING 1
CORECLR_PROFILER {E5A4ADC4-C749-400D-B066-6AC8C1D3790A}
CORECLR_PROFILER_PATH /home/YourKit-NetProfiler/bin/linux-x86-64/libynpagent.so

To add a new app setting, click New application setting. After new settings are saved application should restart with profiling enabled.

New ASP.NET application setting

Connect to the profiled application from the UI

Use Profile remote application... action on Welcome screen or in Profile menu.

Profiler remote app on Welcome screen

Choose the YourKit Connection Broker discovery method.

YourKit Connection Broker discovery method

Provide broker URL and broker access token in the corresponding fields.

YourKit Connection Broker settings

Created connection will appear in the Monitor Applications list on Welcome screen.

Open ASP.NET application in a browser to make sure .NET runtime is loaded. Profiled application will appear in the list, from which you can click on it to connect.

monitor applications

Stop profiling

To disable profiling, set CORECLR_ENABLE_PROFILING application setting value to 0. Alternatively, remove all settings added on previous steps.

YourKit uses cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content and targeted ads, to analyze our website traffic, and to understand where our visitors are coming from.

By browsing our website, you consent to our use of cookies and other tracking technologies in accordance with the Privacy Policy.