How to: Remotely debug an Azure Web APP?

This post is in continuation of the post where I have explained how to host an Azure web app. In this post, I am going to show how to debug an Azure web app remotely. For the demo purpose, I have created a new web project and published the website on Azure following the steps in the post with one difference. For this demo, I have hosted the web app using Debug profile (and not Release profile) as we want to remotely debug website.publish-debug

To start with, I am going to use Visual Studio 2015 Update 3. Below are the steps for remote debugging:

  1. Create and host the web app from Visual Studio.
  2. Open the web application project in the Visual Studio, if not already, and then go to View -> Cloud Explorer                                    cloud-explorer-1
  3. Click on “Connect to Microsoft Azure” link. Please login with your Azure Account. If you have signed into Visual Studio with the same credentials before, it might login automatically or else, might ask to reenter the credentials. azure-login
  4. Once you have successfully logged in, you can select the check box for the subscription which has the web app.            cloud-explorer-2
  5. Click on Apply. You should be able to see all your Azure Resources. Look out for the node for Web Apps. Expand it and right click on the web app you want to debug. Click on “Attach Debugger”.  attach-debugger
  6. It will trigger the remote debugging.enabling-remote-debuggung
  7. If you see the below message, republish your webapp under debug profile as stated before:ready
  8. Once the web app is opened in the browser, set a breakpoint in your code in Visual Studio and browse the site in the browser. In the demo, I have set a breakpoint in Home Controller on About Action Method.about-2
  9. When we click on About menu, it triggers the breakpoint.about-1                       ————————————————————-about-3

Microsoft has made debugging an Azure web app very simple from Visual Studio. Hope the steps shown in this post will be helpful to the reader!