Windows Azure Websites (WAWS) provides a very robust, yet easy to use container for hosting your web applications. This doesn’t just pertain to ASP.NET apps, but includes several templates like Drupal, Wordpress, Orchard, etc. and also provides very nice first class support for Node.js web apps/APIs, PHP and Python.
If you are new to WAWS, you may think ‘big deal, this is just another web host’. You would be wrong. There is a TON of value that you get with WAWS that blows your congenital, commodity web hosters away:
- The free version allows you to host up to 10 sites in a multi-tenant environment and provides a great dashboard, FTP and continuous deployment capabilities including first class support for git (local repos) and github.
- The shared version adds support for seamlessly scaling your app up to 6 instances/nodes along with enabling Web Jobs which provide worker processes for executing jobs on a schedule, continuously or on-demand.
- The standard version allows you to dedicate not instances, but full VMs to your application and supports auto-scaling your app based on metrics and triggers.
These are just the big rocks… there’s a ton more to WAWS and whether you are a .NET, Node.js, PHP or Python developer and there’s a ton of goodness to WAWS which you can learn more about here: http://www.windowsazure.com/en-us/documentation/services/web-sites/
When you create your WAWS application, you get both an IP and URL. The URL takes the form of [your app].azurewebsites.net. This is cool for development, testing and maybe corporate apps, but if you are building publically visible web apps or APIs, chances are you’ll want your own domain name so that instead of [your app].azurewebsites.net you can point your users to foobaz.com or whatever.
Microsoft has official docs on how to do this here, but I found that there was a lot of detail that might intimidate folks so I thought I’d break it down in 4 simple steps. I’ll assume that you’ve already bought your shiny new domain name from a registrar and that it’s parked at some annoying, ad infested landing page.
Step 1: Ensure your site is configured for shared or standard mode
Free doesn’t support custom domains which seems pretty reasonable to me. If you started with a website in free mode, simply click on the Scale option and choose from “Shared” or “Standard” mode and click OK:
Step 2: Copy the IP and WAWS URL
The next step is to make note of your URL and IP address which you’ll need for the third step in this process. Go to the list of WAWS sites, select the site (but don’t click on it) and click on the “Manage Domains” icon at the bottom of the command bar:
This will bring up a dialog that includes your current domain record ([your app].azurewebsites.net) and your IP:
Step 3: Update the A Record and CNAMEs
Make a note of each and login to your domain registrar’s console. You want to look for “DNS Management” and either “Advanced” or “Manage Zones” or “Manage DNS Zone File”. You want to get to whatever console allows you to configure your A Record and CNAMEs. I won’t get into a bunch of DNS theory here, but in a nutshell, these records allow for requests to your registered domain name to be forwarded to Windows Azure, and specifically your website’s host name. The result is that your website will resolve to both [your app].azurewebsites.net and foobaz.com (or whatever domain you purchased).
Each registrar will obviously look different, but this is what GoDaddy’s looks like (there’s several other entries like ftp, MX records, etc. which can be ignored):
The A record needs to point to the IP address you captured in step 2. Replace whatever value is there with the IP address provided. When someone calls up foobaz.com, your registrar will authoritatively answer that request and then pass it on directly to the IP address you provided.
Now there are various docs, posts, etc. that will tell you that you can choose to use an A name record or a CNAME alias but my experience was that I needed to configure both. If you want to try one or the other, go ahead and do so and skip to Step 4. If it doesn’t work, come back and do both (I had to).
For the CNAME, there are 3 entries you need to make:
- Point www to [your app].azurewebsites.net – this tells DNS that [your app].azurewebsites.net should be the destination (canonical host) for any DNS queries that begin with www (i.e. www.foobaz.com)
- Point awwverify AND awwverify.www to awwverify.[your app].azurewebsites.net – This provides for a DNS validation mechanism so that WAWS can validate that your domain registrar has been configured to allow WAWS to serve as a canonical domain in the event that a CNAME look up fails.
Be sure to save your file/settings.
Step 4: Enter your custom domain name in the Manage Domains dialog and check for validity
Pull up the “Domain Settings” for your website again, and this time, enter your new domain name (i.e. foobaz.com). If you want WAWS to respond to both www.foobaz.com and foobaz.com, you’ll want to create both entries. You’ll likely see a red dot indicating that validation and/or CNAME look up has failed:
Note that DNS can take up to 48 hours to propagate so as you move to this step, know that if it doesn’t immediately work, wait a few hours to a day and try again (Dynamic DNS providers solve this problem by acting as a proxy between your authoritative domain and canonical domains/IPs). It is very likely that you’ve done everything right, but the records have not yet propagated.
This is simply WAWS’ way of telling you that the records have not yet propagated. You can happily continue using your WAWS website using the [your app].azurewebsites.net URL. In time, when you come back to the dialog, the verification should succeed and any request for foobaz.com should automatically resolve to your WAWS app.
If you’ve followed these steps and still have issues after 24-48 hours, feel free to drop a comment or hit me on twitter @rickggaribay and I’ll be happy to help you out.