Automating Dump Captures with Auto-heal

I came across an issue where I needed to collect a memory dump of the Hybrid Connection process on an app service (workerforwarder). This issue was we needed this to automated based on thread count and the default mechanisms in app services did not support capturing a dump of this process.

The second issue is running procdump requires specifying the process ID or process name. Since there’s two processes, one for the main w3wp.exe both with the name workerforwarder, I had to devise a script to capture a dump of both process.

I used the script below to run a custom Action from Auto-Heal.

Script

Start-Transcript Dumplog.txt -Append
 
get-date -Format "dd.MM.yyyy HH:mm:ss"
 
$task = get-process -name workerforwarder
 
$task[0].Id
d:\devtools\sysinternals\procdump -accepteula -ma $task[0].Id
 
Start-Sleep -Seconds 5
$task[1].Id
d:\devtools\sysinternals\procdump -accepteula -ma $task[1].Id
 
Stop-Process -Id $task[0].Id
Stop-Process -Id $task[1].Id
 
$taskw3wp = get-process -name w3wp
 
$taskw3wp[0].Id
$taskw3wp[1].Id
 
Stop-Process -Id $taskw3wp[0].Id
Stop-Process -Id $taskw3wp[1].Id
 
Stop-Transcript

Auto-Heal Setup

Command: PowerShell.exe -command “D:\home\site\dump.ps1”