How To Collect Memory Dump From Azure App Service?

How to collect memory dump from Azure app service?

How to collect memory dump from Azure app service?

When to collect the memory dump?

Since the data in the machine memory is changing very fast, and the dump file is like a photograph of one specific time, the dump is useful only if it was captured when the issue was happening.

Why the dump is helpful?

A dump file has the threads that were executing, and their callstacks, loaded modules, Memory heap, etc. By analysis that information, we can know what was happening during the issue time and get the conclusion of the cause.

Approach #1: How to collect Memory dump without procdump.exe ?

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

  1. A *.dmp file is downloaded. 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.


Approach # 2: 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 https://learn.microsoft.com/en-us/sysinternals/downloads/procdump, 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

  1. Go to Debug Console -> CMD.
  2. In the command window, navigate to the dumps folder.
  3. 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, refer to the following article: How to collect memory dumps using ProcDump? .