Reading a static variable in an Azure App Service
Visit the Kudu site
The URL for a Kudo site is normally just https://contoso-images.azurewebsites.net
with scm
put inbetween the host and the .azurewebsites.net
bit.
So https://contoso-images.azurewebsites.net
becomes https://contoso-images.scm.azurewebsites.net
.
You can otherwise use the handy script below:
Generate a full memory dump
Inside of Kudu's online interface, goto Debug Console -> Powershell
via the menu at the top, then use the following script to generate a memory dump. The SysInternals tools are alreay installed on the machines by default.
$targetPID = (Get-Process | Sort-Object -Property "StartTime" | Select-Object -First 1).ID
& "D:\devtools\sysinternals\procdump" -accepteula -ma $targetPID
It will take a little bit to dump the memory to a local file. Which you can then download by clicking the icon circled below:
Download all the code
Using the same window as above, click on site
, then click on the download button next to wwwroot
.
This will download a ZIP of the code running on the site.
Use dotPeek to decompile the C# Project
Install dotPeek however you like, then start it up and follow these steps:
Add the files downloaded from Kudu to dotPeek
.
Start the Symbol Server
Start the Symbol Server using the button shown below:
Open the memory dump and set the symbol server
Open the memory dump in Visual Studio. Use the option Set symbol paths
to open the Options
menu, then the +
to add the dotPeek url http://localhost:33417
to the studio.
Start Debug with Managed Only
Use the button top-right Debug with Managed Only
, which'll start-up the debug instance. This will look like you've hit a breakpoint, but without any code showing.
Swap thread to... something
Honestly I have no idea what this is for. But go to Debug -> Threads
, then pick any thread that has text next to it.
Use the immediate window to show the static variable
Open the Debug -> Immediate Window
, then, in the new Immediate Window type the full name of the static variable you'd like to read.