Practicing Microsoft Azure: Part 11 (Debugging Azure Websites)

Before reading this article, I highly recommend reading the following previous parts:

This article is especially designed to show remote debugging of ASP.NET websites deployed in the cloud Azure environment because usually, a huge number of applications run in production with inherent bugs that can create great mayhem later. However, it is relatively easy to debug a web application locally, but we can also perform sophisticated debugging to the web application that are uploading or run in the Azure environment. The sample web application built in ASP.Net in this article, is performing a typical addition of two numbers and unfortunately the developer inadvertently forgot to check the input type handling. After uploading this web application, we will observe the cause of the error by doing remote debugging.

Step 1

First create an ASP.NET web application by choosing the Web Form template from Visual Studio new projects and assign a meaningful project name as in the following.

create app

Step 2

After placing the essential text box and button control in the design view, place the following code about the two number additions in the button click even handler as in the following.

Notice, in the previous code, we didn't handle the proper input type. That will cause mayhem when entering the wrong type of input.

Step 3

Simply test the application locally to ensure it works correctly before uploading to Azure.

Step 4

Now, open the Windows Azure Development portal to create a new website, however you can do this without the Azure portal, using the Visual Studio IDE itself. Here, create a new website, clrAzrDebugTesting, via the quick create option as in the following:

Step 5

Now, publish the local ASP.Net website into Azure once the website is created, using the Publish option as in the following:

Step 6

Since the website uploading process is slightly different than the cloud service. In this way, it shows some various types of wizard dialog box. Here, choose the Window Azure web sites option since we have created the ASP.NET website as in the following:

Step 7

It is necessary to be signed in with our Azure account. Once logged-in, you will find your previously created website through the development portal. Thus, choose it and proceed.

development portal

Step 8

Next, choose the publish method as Web Deploy in the following dialog box. The rest of the parameters are automatically assigned, you don't need to bother about them.


Step 9

Next, the very important step to do here is to choose Debug configuration since we are showing the remote debugging process of a web application.

Step 10

We are nearly done, you can even see the preview here before finally publishing the website in Azure as in the following:

Step 11

Finally, the wizard initiates the website uploading process that took some time to complete. Once finished, show the status as successful.

Step 12

After publishing, the Azure development portal dashboard shows this website as being the in the running state as in the following:

Step 13

Just dully ensure once, either the website is running perfectly or not by entering the Azure cloud URL as in the following:

Step 14

Now, return yo the Visual Studio IDE, open the Server Explorer, choose your website by expanding the website section and select "Attach debugger" after right-clicking as in the following:


Step 15

Now, open the ASP.NET project and place a breakpoint in the code file here as in the following:


Step 16

Now, the application is in a browser. Enter some invalid input, other than numeric and hit the Addition button as in the following:

addition btn

When you hit the Addition button, the breakpoint in Visual Studio will be activated automatically, now you can magically debug your application by examining the entered value, whether it is in the correct form or not.

So like this, in this article we have acquired an adequate understanding of how to debug a website remotely that is already deployed in the Azure production environment.