Remote Debugging Azure Cloud Service

We can debug a production cloud service hosted in Azure through Visual Studio. Yes, you can step through the code of a cloud service hosted in a live production environment! And, its very simple. In this post, I’ll explain how to enable remote debugging on azure cloud service and how to step through code. The remote debugging is disabled by default on a cloud service. It needs to be explicitly enabled when the service is published on Azure. There are two ways. I’ll use pictures to explain, because they speak more than words!

First, when creating the cloud service package to manually upload into the azure…

Remote Debugging Azure Cloud Service

Remote Debugging Azure Cloud Service

Second, when publishing a cloud service to the Azure directly through Visual Studio…

Remote Debugging Azure Cloud Service

Remote Debugging Azure Cloud Service

In the above dialog:

  1. First screen, Sign In with your Live Account with Active Azure Subscription and Press “Next” (1)
  2. Enter the required details on the “Common Settings” tab.
  3. Click on “Advanced Settings” (2)
  4. Check “Enable Remote Debugger for all roles” (3)
  5. Click on “Publish” (4)

The service can now be debugged through Visual Studio.

  1. Open “Server Explorer” > “Windows Azure”
  2. Expand “Cloud Services”
  3. Expand the required “Cloud Service” and expand to the required “Worker Role” or “Web Role”
  4. Right-Click on it and Click “Attach Debugger”

Remote Debugging Azure Cloud Service

Once the debugger is attached, set a breakpoint in the code and try invoking the service that will hit the breakpoint. You can now step through the code as if it were running on your local machine!

Things to take care,

  1. Keep the cloud service project open, the one which is deployed.
  2. Make sure there are no code changes to the local copy of the project after it is deployed, else stepping through code may not work smoothly.
  3. If the execution is paused for a long time, step through is done slowly or a lot of execution paths are modified in the editor, the health of the cloud service degrades. The cloud service needs a restart to fix it.
Share This!

2 thoughts on “Remote Debugging Azure Cloud Service

Leave a Reply

Your email address will not be published. Required fields are marked *