Advanced troubleshooting for Sitecore XP on Azure Web Apps


Description

This article reviews tools and methods to collect information to use for troubleshooting a Sitecore XP application on Azure Web Apps.

The following sections describe ways to gather relevant data for typical performance issues, such as:

KUDU Toolset

Microsoft Azure Web Apps (App Service) comes with the KUDU toolset enabling extended low-level diagnostics access for troubleshooting web applications.

To run KUDU for your Sitecore XP application deployed to Azure Web Apps, use the following URL:
https://<name-of-AzureWebApp>.scm.azurewebsites.net/

Note: You must be logged in to the Azure Portal and have access to a particular Resource Group as a Contributor.

Collecting A Memory Dump Using Procdump Utility

Azure App Service instances include the Sysinternals suite in the default image. They can be located at this path via the KUDU console: D:\devtools\sysinternals.

It is also possible to download the ProcDump tool from here, upload it to a specific location such as D:\home\Dumps and use it.

To collect a memory dump:

  1. Open KUDU and go to the Process Explorer.
  2. Note the PID (Process ID) of the w3wp.exe process corresponding to the application.

  3. Go to Debug Console -> CMD.
  4. In the command window, navigate to the dumps folder.
  5. Execute the following command to generate a full memory dump of the process:
    procdump.exe -accepteula -ma [PID of the process]
    -ma — write a dump file with whole process memory.
    -accepteula — automatically accept the Sysinternals license agreement.

Note: When the manual memory dump collection is not appropriate, the Procdump utility provides the ability to specify different conditions for when to automatically collect a memory dump. For more information on this topic, please refer to the following article: How to collect memory dumps using ProcDump.

Collecting A Memory Dump Using Process Explorer (On-Demand)

To collect a memory dump:

  1. Open KUDU and go to the Process Explorer.
  2. For the w3wp.exe process (not SCM), right-click to access the context menu.
  3. In the context menu, click Download Memory Dump -> Full Dump:

    A *.dmp file is downloaded. You can analyze it using a common tool, such as WinDbg.

Note: To ensure that the memory dump is analyzed properly, you must have the SOS.dll file from the target OS.

To get the SOS.dll file:

  1. Open KUDU and go to Debug console -> CMD.
  2. Navigate to the system drive using the button at the top.
  3. Locate the SOS.dll file in an appropriate .NET Framework folder (for example, C:\Windows\Microsoft.NET\Framework64\v4.0.30319).
  4. Download the SOS.dll file.

Collecting A Memory Dump Using Diagnostics As A Service (DaaS)

To collect a memory dump via the Azure portal:

  1. Login to the Azure portal (https://portal.azure.com).
  2. Select the Azure Web App that you need to troubleshoot.
  3. Click Diagnose and solve problems and then click Diagnostics as a Service:

  4. In the new blade, set the following fields:
    • Application Type – set the value to ASP.NET.
    • Diagnosers – select the Memory Dump check box. If you want Event Viewer Logs and Http Logs, you can select these check boxes too.
    • Instances – if the App Service Plan is configured to use more than one instance, you can configure this field to collect the logs on either all instances or specific instances.

  5. To collect the logs, click Run . The blade indicates the status of the operation and runs analysis on the collected data. The data is saved under the D:\home\data\DaaS\Logs folder.

Collecting A Performance Profile

To collect a performance profile:

  1. Open KUDU and go to the Process explorer section.
  2. For the w3wp.exe process (not SCM), check the "Collect IIS Events" checkbox and click Start Profiling.
  3. Request your web application home page and, to ensure that profiling is running, click Refresh on the KUDU page.
  4. Reproduce the performance issue in your web application.
  5. Go back to the Process explorer section in KUDU.
  6. Click Stop Profiling.

After the process is finished, a profile_*_w3wp_*.diagsession file is downloaded to your PC.

To further analyze the downloaded file, open it in Microsoft Visual Studio: