Azure App Service: Manually collect memory dumps
While troubleshooting web application performance issues we are sometimes required to gather memory dumps during the time of the issue. In Azure App Service, we do not have RDP access to the machines. However, this doesn’t restrict us from gathering logs & data for troubleshooting. I am listing out few methods using which we can generate memory dumps of the process during the time of the issue.
Method 1: Using ProcDump.exe
Azure App Service instances include the sysinternals suite in the default image. They can be located here via the KUDU console: D:\devtools\sysinternals The users may also download ProcDump fromPre-Requisite: For this we need the sysinternals utility: ProcDump.exe
here and upload it a specific location such as D:\home\LogFiles\Dumps and use it.
-
Browse to the KUDU console
-
Click on Process Explorer menu.
-
There will be 2 w3wp.exe processes, one for SCM (KUDU) and another for the application.
</ul>
-
Note the PID (Process ID) of the w3wp.exe corresponding to the application (see the image above)
-
Browse to Debug Console –> CMD
-
In the command window, navigate to the dumps folder.
-
Execute the following command to generate a full memory dump of the process
</ul>
procdump.exe -accepteula –ma </font> </td> </tr> where,
-ma Write a dump file with all process memory. The default dump format only includes
thread and handle information
-accepteula Use this switch to automatically accept the Sysinternals license agreement.
Method 2: Using Diagnostics as a Service (DaaS)
Via Portal:
-
Login to Azure portal. (
-
Select the Azure Web App that you intend to troubleshoot
-
Click on Diagnose and solve problems.
</ul>
- In the new blade click on Diagnostics as a Service. (Bottom right side of the blade.)
- In the new blade, set the following:
- Application Type – Depending on the type of application set the value to ASP.NET or PHP or Node.js.
- Diagnosers – Since this post is about collecting memory dumps, ensure that the check box against Memory Dump is selected. If you need Event Viewer Logs & Http Logs then you can enable them too.
- Click on Run to collect the logs. The blade will indicate the status of the operation and will also run analysis on the collected data.
- This puts the data under D:\home\data\DaaS\Logs folder.
How to connect to the Kudu site of a specific instance
-
Login to the KUDU console and append /daas to the path. (
[http://
.scm.azurewebsites.net/daas</font>](http:// .scm.azurewebsites.net/daas)) -
This will launch the DaaS portal
-
Reproduce the issue
-
Click on Diagnose Now button as shown below:
</ul>
- This will initiate logs collect.
- You can click on Schedule Analysis to select the logs that will be collected and whether you want to run an analysis on that. </ul>
More Information:
DaaS – Diagnostics as a Service for Azure Web Sites
New Updates to DaaS – Diagnostics as a Service for Azure Websites
Method 3: Using Process Explorer (KUDU) (least favorable)
This method is the least favorable as it generates the memory dump and the prompts the user to download it. If the download is interrupted due to some reason then the data is lost.- Login to the KUDU console. ([http://
.scm.azurewebsites.net](http://%3cyoursitename%3e.scm.azurewebsites.net)) - Click on Process Explorer menu
- There will be 2 w3wp.exe processes, one for SCM (KUDU) and another for the application.
- Reproduce the issue
- Right click the w3wp process (without the scm tag) and select Download memory dump –> Full Dump as shown below:</ul>
- Depending on the size of the process it will take couple of seconds or few minutes to generate the dump on the VM and prompt you to download the file
****IMPORTANT****
-
Using Daas via portal is the preferable method. When the web app is scaled out to run on more than one instance, then you can use DaaS to collect the memory dump from a specific instance. Method 2 & 3 will generate memory dump on a specific instance and is not fool proof as the issue may or may not be occurring on the connected instance. You can however connect to the KUDU of a specific instance using my previous post here: How to connect to the Kudu site of a specific instance
-
The downloading of the memory dump will contribute towards the outbound bandwidth of the App service plan. For more details refer: http://azure.microsoft.com/en-us/pricing/details/data-transfers/
-
When the memory dump is being written, the process remains in a frozen state for the entire duration of operation. So this impacts the application’s availability.
-
You can compress the memory dump via 7zip which is availably by default on Azure App Service instances. You can run the following command:
</ul>
D:\home\Logfiles\Dumps>D:\7zip\7za.exe a MemoryDumps.zip *.dmp
NOTE: Compression consumes CPU cycles, so you may want to re-consider when running this on a Small sized instance
-
-
-
- Right click the w3wp process (without the scm tag) and select Download memory dump –> Full Dump as shown below:</ul>
- Reproduce the issue
- There will be 2 w3wp.exe processes, one for SCM (KUDU) and another for the application.
- Click on Process Explorer menu
- You can click on Schedule Analysis to select the logs that will be collected and whether you want to run an analysis on that. </ul>
-
Click on Diagnose Now button as shown below:
-
Reproduce the issue
-
This will launch the DaaS portal
- Application Type – Depending on the type of application set the value to ASP.NET or PHP or Node.js.
-
Click on Diagnose and solve problems.
-
Select the Azure Web App that you intend to troubleshoot
-
Execute the following command to generate a full memory dump of the process
-
In the command window, navigate to the dumps folder.
-
Browse to Debug Console –> CMD
-
There will be 2 w3wp.exe processes, one for SCM (KUDU) and another for the application.
-
Click on Process Explorer menu.