Passer au contenu principal

 Subscribe

Azure Web Apps as well as API Apps and WebJobs can now be remotely profiled. If your process is running slower than expected, or the latency of HTTP requests are higher than normal and the CPU usage of the process is also pretty high, you can remotely profile your process and get the CPU sampling call stacks to analyze the process activity and code hot paths.

There are three ways to profile a process in Azure App Service and get the CPU usage report:

  • Using Visual Studio 2015
  • Browsing the Azure App Service’s Site Control Management dashboard (aka kudu)
  • Using REST APIs

 

Profiling is not supported on free or shared sites. The site needs to be upgraded to Basic or Standard in order to be profiled. Also note, CPU profiling works best with .Net apps.

Profiling using Visual Studio 2015

Follow the steps below for profiling using Visual Studio 2015:

  • Open Server Explorer (View menu > Server Explorer or CTRL+W, L).
  • Expand Azure, App Service, your Resource group then right-click the app’s node and select the Start Profiling gesture.
  • The remote profiling session will start and you can run your scenario and the CPU samples will be collected in Azure for your process.
  • Once you stop the remote profiling session using the Stop Profiling gesture, the profiling data collected in your Azure Web App will be downloaded and opened in Visual Studio 2015.

 

Remote Profiling support in Azure App Service

 

You can repeat the same steps to profile an API App or a WebJob under the WebJobs section of a Web App. If your Web App is running on multiple instances, VS will pick one and start a profiling session on that instance only.

For more info about Azure SDK 2.7 check out the Azure SDK 2.7 for .NET announcement.

For detailed information about new debugging and profiling features in Visual Studio 2015 visit Performance and Diagnostic Tools in Visual Studio 2015.

Profiling using the kudu site

Follow the steps below to profile using the kudu site:

  • Navigate to your site’s scm endpoint (.scm.azurewebsites.net).
  • Click on Process Explorer. Here you will see all the processes running in the site’s context(sandbox).
  • Click the Start Profiling button for the process you wish to profile, (most likely the w3wp.exe process).
  • Run your scenario, then click the Stop Profiling button.
  • After few seconds, the browser should bring up the file download option. You can save the profile and view it later or open it in Visual Studio 2015.

 

Remote Profiling support in Azure App Service

 

It is not recommended to run a profiling session for more than one to two minutes because profiling can produce large files. The profiling session will be terminated if a session is started from the kudu site and is running for more than 15 minutes.

If your Web App is running on multiple instances, you can connect to the scm site for the instance you’d like to profile and start a profiling session on that instance only.

Profiling using REST calls

You can use kudu endpoint to start and stop a profiling session using REST calls.

To start a profiling session: POST /api/processes/{process id}/profile/start

To stop a profiling session and download the profile: GET /api/processes/{process id}/profile/stop

Viewing profiles

The generated profile is a .diagsession file which can be opened with Visual Studio 2015. If VS 2015 is not available, you might be able to rename the extension to a .zip file and open the .etl file inside the zip in any tool which understands ETW events.

Once you open a profile in VS 2015 you will see the all familiar profiling pages where you can easily drill down into specifics of your profiling sessions and locate the bottleneck. Below is a sample profile session from an application suffering from a prolonged period of high CPU.

 

Remote Profiling support in Azure App Service

 

You can click on Create Detailed Report to see more details about the profiling session.

  • Explore

     

    Let us know what you think of Azure and what you would like to see in the future.

     

    Provide feedback

  • Build your cloud computing and Azure skills with free courses by Microsoft Learn.

     

    Explore Azure learning


Join the conversation