Another Cool Way to Remotely Debug Azure Web Sites

When I was working on a project last week I was having some problems getting the debugging experience working correctly between Visual Studio 2013 and my code which was running in an Azure web site.  Fortunately a really smart guy that works here, Petr, gave me a set of instructions to get debugging started another way.  He said it was posted in a blog article somewhere so with all due deference…I’m posting the steps and a picture or two here because I didn’t happen to find it when I was looking, so perhaps the more blog posts on this topic the easier it will be to find.  :-) 

The particular issue I hit required me to attach the debugger, but not in the way I have typically seen to to do it, which is by selecting the web site from within the Visual Studio Azure resources list, then choosing the Attach Debugger menu item.  In this case, I needed the application to be up and running and already logged in via the browser to the site.  So given that, here’s how you can attach to any Azure web site.  To begin with, first you want to go in and make sure that remote debugging is enabled for the web site.  Visual Studio sets this to true when you attach the debugger through it, but it only lasts for 48 hours and then it resets.  The same holds true even if you set it manually, so you’ll need to go in and check each time before you start debugging.  To get there, just go into the Azure management portal, click on your web site, then click on the Configure tab.  Scroll most of the way down and you’ll see this switch for enabling remote debugging; just set it to “ON”.


After you’ve turned it on and saved your changes you can follow these steps that Petr provided to me to start debugging:

  1. Download the publishing profile for your Azure web site and save it locally, then open it up in Notepad.  You’ll need to copy some values out of it later.
  2. If you haven’t already, open up your browser and navigate to your Azure web site to make sure it’s up and running.
  3. In Visual Studio have your project open, the click on Debug…Attach to Process.
  4. Change the Qualifier to yourSiteName.azurewebsites.net and then click the Refresh button.  See the picture below if you’re unclear what I mean.


  1. After you click the Refresh button you should get an authorization window.  For the username type in “.\” and then paste in the userName attribute from the publishing profile.  It should be something like $yourSiteName, so you what you type in for the user name should be .\$yourSiteName.
  2. Paste the userPWD attribute in as the password.  Visual Studio should then be able to connect to the Azure web site and show you some processes.  There may be one or more MSVSMON processes, but only one w3wp.exe process.  Attach to that.

That’s it.  You should be attached to your Azure web site code now and ready to start debugging.  Hope this helps someone.

5 thoughts on “Another Cool Way to Remotely Debug Azure Web Sites

  1. Thanks for sharing this tip. I need this alternative to get me started because, for some reason, I can’t log into my azure account from VS 2013 Server Explorer. I could follow your tip and get process attached. However, it doesn’t hit my break points. Can you tell why? I also tried to attach to Node.exe (which is what I’m using), but it doesn’t break either.

    Like

  2. After changing remote debug to on, and downloaded the publishing profile, I didn’t use it to publish, so the server still have the release version published previously. I thought that might be the problem. So, I published it again using the new profile. One change I did observe: I can’t set break point in VS now – it shows as solid red dot instead of white dot. However, I still cannot hit the break point.

    Like

  3. unable to attach debugger , my website name is “http://qa-mydemo.azurewebsites.net/” is it because of “-”
    kindly reply back how to troubleshoot ?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s