Moving Your Website to Azure

In this section, I will show you how to port your Web Application to Windows Azure. In the next section, I'll show you how to port your SQL database to Windows Azure (note: Azure has a number of other Database options if you are using a non-Microsoft SQL database).

The instructions below show you how to port an ASP.Net WebForms application to Azure. Try this article if you are developing for the ASP.NET MVC 3 platform.

At this point, you should have a Web Application that you are ready to port to Azure. If you have a Web Site Application instead of a Web Application, please read the previous section on how to convert a website into a Web Application.

  1. First, you will need a “Live” account. If you don’t have one already, go to and sign up. If you already have a personal account, but are setting up a website for work, consider creating a second account using your work email address. Before signing up, take a moment to decide if you want to use your own email address or a or address for this account. Like Facebook and Google, Microsoft is also creating a single sign-on account that you can use across websites and technologies. For example, you will be able to use your account to login to a Windows Phone, or an XBox, or various Microsoft websites (e.g. msdn). In addition to giving you a (semi-)universal login, you can also use as an aggregrator, by letting it collect information from your social networking accounts (Facebook, Twitter, LinkedIn, etc.), RSS feeds, Photo accounts, other email accounts, etc., so that you can view them all in one place (or even on your phone). The reason I mention all this is because you might want to take your time when setting up your new account, as you may be using this account for a very long time.

  2. Sign up for Azure at Sign up for the free trial. You will need a credit card to do this (recently, they do have some deals that don't require this, but I suggest using the credit card anyway -- see below), and you will need your Windows Live login email and password. You may think that when the "free trial" parameters are reached , that your credit card will automatically be charged. This is not the case. By default, your credit card has a $0.00 spending limit. If you don't want to be surprised by a suspended acccount (as I was), then you should follow these instructions to remove the spending limit.

  3. You can use this link for Azure Support. As mentioned above, I discovered that I had neglected to remove my spending limit, and my account was suspended. This happened to me on a Saturday of a 3-day holiday weekend. I never had high expectations for Microsoft Support, but I was amazed to have a Microsoft employee call me on the phone on a Saturday shortly after I submitted a ticket requesting that they re-activate my account. Shortly after the first call, my ticket was escalated, and Rob Dil, another Microsoft employee called me and quickly had someone re-activate my account even though the Azure Free Trial Pricing page said I would have to wait until the end of the billing month before my account was re-activated. If you've been reading this article from the beginning, you should be very surprised at this high level of support. If any Microsoft employees are reading this, please nominate Rob Dil for a raise or a bonus or employee of the month or whatever you people do for stellar employees at that giant corporate behemoth.

  4. After you have signed up for Azure, you need to install some tools.

    It’s a good idea to make sure you have all the Visual Studio updates and service packs installed before you install the Azure Tools; go to to get these).

    For best results, you will want to do install the Azure tools on a machine that has Visual Studio 2010 SP1 (or later) installed. If you don’t already have a machine with Visual Studio 2010, the following installation will install Visual Web Developer 2010 Express (I’m not familiar with this product, but I’m guessing you can do what you need to do with it).

    Click on “Manage” (look in the top right of your screen, if you don’t see it, click on the “Home” link). If you are given a choice between “Use the New Portal”, and “Use the old Portal”, choose to use the new portal. Click on the link that says “Get Windows Azure tools for Visual Studio…”. Click on the link that lets you fully install the .net tools. Install Azure Tools

  5. Before we deploy our application, let's take a quick step to setup an "Affinity Group". This will help us save money later. As of this writing, Azure charges for outbound bandwidth. That is, if you upload a bunch of data to your Azure instance, you pay nothing. If you (or your customers) download a bunch of data from one of your Azure instances, then you pay for that bandwidth. Now, let's say you have a Web role and a non-SQL Storage role running on Azure, and these two roles "talk" to each other. Perhaps the Web role displays data that it reads from the Storage role. In this case, you will be paying for the outbound data's bandwidth from the Storage role to the Web role. By following these instructions to setup an "Affinity Group", you can avoid these charges by putting these two roles into one Affinity Group. This article explains that the Affinity scheme doesn't work with SQL. If your website uses an SQL server as back-end and most of your customers are in the U.S., I suggest you locate both the Web instance and SQL instance in "South Central US", as "North Central US" does not support SQL as of this writing (March 2012). Important Note: As far as I can tell, you cannot change an Affinity Group after you have created the instance.
    New Affinity Group
  6. To make your app deployable to the cloud, right click on the project in Solution Explorer and click “Add Windows Azure Deployment Project”

    Add Azure Project

    Visual Studio will add a new Azure project to your solution with a bunch of new files. One of these files is called ServiceConfiguration.Cloud.csfg. You may wish to edit this file and change the number of instances like this: <Instances count="2" /> This will tell Azure to create two virtual machines to host your website, with a load-balancer distributing your customers' traffic between them. If you create two instances, your customers will still be able to access your website when you deploy updates, since Azure will be able to update one instance at a time while the load balancer cleverly sends your customers to the other instance during the update. The second instance will cost you extra, however. Azure has other options (e.g. creating separate Staging and Deployment environments), but that is beyond the scope of this article.

  7. Right click the application, and choose “Publish to Windows Azure…". Note that we are not using the "Publish" menu item which you would use if your site was hosted at another ISP.

    Publish to Azure

  8. The first time you do this, you will need to click on the link that says “Sign in to download credentials”. You may have to sign into Windows Azure using your Windows Live ID. After a few moments, your browser will ask you to download a file. Save the file, and remember its location.

    Publish Sign In

    This is what you will see after you click on "Sign in to download credentials":
    Download Credentials

  9. Then, go back to the “Publish Windows Azure…” dialog, and click on Import. Navigate to the file you just downloaded, click “Open”, and then click “Next”.
  10. You will be prompted to create a new Hosted Service if you have not already created one on the Azure platform. If your website's customers are in the US, and your website uses an SQL Server backend, then I suggest you choose South Central US, as North Central US doesn't currently support SQL, and you will want to have your Web role and Sql Role in the same datacenter so that your website has better performance (you want your website queries to the SQL server to be fast, not subject to cross-country round-trips). If you created an Affinity group above, then you should probably choose this, although the Affinity Group won't help lower your billing costs if you are using SQL instead of one of the other database options offered by Azure.

    You might want to take a moment to consider what you want to name your hosted service, as Azure will create a DNS name based on this hosted service. You will still be able to point your domain name at this new website, but there are some cases where users and search engines will still be able to view the site using this * domain name, so take some time to figure out a good name.
    Create Hosted Service

  11. We need to enable Remote Desktop (RDP) so that we can later check on hacker activity and mitigate (and yes, there are other ways to do this, e.g. PowerShell, but for now, let's use RDP). Click on the checkbox that says "Enable Remote Desktop for all Roles", and follow these instructions to setup the certificate for Remote Desktop. Once your website has been deployed, you can use the techniques I described previously (netstat, reading log files, etc.) to combat the hacker.
    Publish Settings and RDP

  12. Enter a username and password (twice) that you will later use to login (via RDP) into your Azure virtual instances. The password must be complex (e.g. upper and lowercase, etc.).
    RDP Settings

  13. Now, click on the Publish Button.

  14. In Visual Studio, you will see a window that looks like this. Click on the arrow to expand the display. Publish Azure Collapsed

    This is what the expanded window looks like:
    Publish Azure Expanded

  15. Once the deployment is complete, you can click on the "Website URL" shown to view and test the website.
    Publish Azure Complete

  16. Next, you will want to setup your domain to point to this website by following the instructions in this article . Note that the DNS instructions are a little different than what you might be used to. is a CNAME to your address, and is a "forward".

  17. If your web application needs access to an SMTP server (e.g. so your customers can use a Contact form to send you email), you might need to change your SMTP configuration/code to use another server if you've been using "localhost", as Azure doesn't support this as far as I can tell. Here is some info on how to setup SMTP using Gmail. Here is an article on how to setup SMTP using Office 365. Here is a general purpose article on How to send email from a Windows Azure Application.

  18. Read this article on URL Rewrite Support in Windows Azure if you are using SEO-friendly URL rewrites.

  19. If your web application needs to be able to write to local files, you should check out this discussion on using Azure's Local Storage. Additionally, Azure provides a number of other storage options, some of which are described in the Windows Azure Drive White Paper.