Step-by-step: Migrating ASP.NET Application to Windows Azure (Part 3–Converting ASP.NET Web site to Web Role)

This is the third post of Migrating ASP.NET Application to Windows Azure series. You are encourage to read my first post about Preparing the ASP.NET Application and the second post about Preparing SQL Azure Database if you have not do so. Without further due, let’s get started.

Before conversion, do note that web role is actually ASP.NET web application++, not ASP.NET website. If you are not sure about the difference, please go through the following blogs and discussion about that:

The ++ that I’ve mentioned before is some additional files as well as minor changes as following:

  • WebRole.cs / WebRole.vb which derived from RoleEntryPoint that functions for initiating the configuration of your Windows Azure WebRole project.
  • If you notice your web.config file, there would be an additional section as following:

<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type=""/>
</add>
</listeners>
</trace>
</system.diagnostics>

This section of the code enable us to perform Windows Azure diagnostic monitoring by injecting the trace listener. I encourage you to read this reference to learn more about Windows Azure diagnostic.

Alright, now let’s get our hand dirty to convert the core application.

I’ll continue the steps that are done in the first post here. We have 3 projects in our solution: namely the Website personal, CloudServicePersonal,and PersonalWebRole.

1. As we need to align our webrole with the website personal content,we need to delete the unused files in default WebRole project. On the WebRole project “PersonalWebRole”, delete the default.aspx and web.config file. Note that, if we want to implement the diagnostic, we’ll need to manually add those diagnostic section later on.

2. Next step is to copy the entire content of the website personal to the PersonalWebrole. Block all of the content from personal website and drag it to PersonalWebRole. Alternately, you can do so by copy the website personal and paste it on the PersonalWebRole.

image_2127B787 image_2BD4E90F

If it prompts for merge folders, check “Apply to all items” and select “Yes” to merge.

3. Remembering that ASP.NET Web Role is based on ASP.NET Web application, not web site, we will need to convert the aspx files to web application so that it contains the .designer.cs file. To do that, right click on the PersonalWebRole and select Convert to Web Application.

image_5075DAB9

4. You may delete your personal website as we don’t need to use it anymore.

5. Try to build the solution to check if any error occurs.

6. As hosting your application on Windows Azure is somehow different with traditional web application, we’ll need to examine the code whether they are all valid.

Some example of invalid code could be found in App_CodePhotoManager.cs, ListUploadDirectory() method since it tries to get the detail directory info of “upload” folder. Comment this method.

image_33E8C30C

We’ll also need to comment any other code that call that method such as AdminPhoto.aspx.

image_5610A8C5

In some case where you really need the similar functionality, of course you’ll need to modify it as required to be ready to run on Azure. For example, If your ASP.NET Website allow people to upload and store the file on file system, you will want  to implement similar feature using Azure Storage Blob. I’ll talk about those stuff on the further post if possible Smile.

Updated on 8 Sept 2010: Please refer this link where I’ve implemented similar functionality for bulk upload

7. Run the web role on the development fabric by pressing F5 or Run. Development Fabric is the local simulation environment of Windows Azure hat implements things like load balancing, etc. Make sure that your website is running well on development fabric first before deploy it to real Windows Azure environment.

image11_5D775101

8. Try to log-in with the credential to see whether it’s running well.

image_6938AA01

9. Congratulation if you’ve done at this step. It means that you have successfully converted your web site to Windows Azure web role, as well as have successfully connected it to SQL Azure.

But wait, you are not done yet! Why? Running well on development fabric, doesn’t mean it will run well on Windows Azure Confused smile.

No worries, in next post, I’ll show you how to deploy it to Windows Azure and solve each problem if there’s any issue arise.

See you!

This entry was posted in Uncategorized. Bookmark the permalink.

4 Responses to Step-by-step: Migrating ASP.NET Application to Windows Azure (Part 3–Converting ASP.NET Web site to Web Role)

  1. Pingback: Nothing found for 2010 09 08 Step-by-step-migrating-asp-net-application-to-windows-azure-part-5-implementing-bulk-copy-from-blob-storage-to-sql-azure

  2. Pingback: Step-by-step: Migrating ASP.NET Application to Windows Azure (Part 1 – Preparing the ASP.NET application) | Wely's Cloud Journey...

  3. Pingback: Step-by-step: Migrating ASP.NET Application to Windows Azure (Part 2–Preparing SQL Azure Database) | Wely's Cloud Journey...

  4. Why users still use to read news papers when in this
    technological globe the whole thing is accessible on net?

Leave a Reply

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

*