After you create a website in Windows Azure Web Sites (WAWS), you can open a browser and see your site by going to sitename.azurewebsites.net. That’s cool, but if you own a domain name, you might want to use it instead. You can do that in WAWS (assuming you are not running in Free mode) by adding your custom domain to the Azure portal, but you have to take care of some changes at your domain registrar before you can do that.
Note: What I’ve documented here isn’t the only way to do this. You may have more complex requirements or a more complex configuration. However, what I’ve outlined here covers a large majority of our customers.
Another Note: If you are using Azure Traffic Manager, use the information located here instead of what’s in this blog post.
A domain registrar is a company that manages your domain. In order to use your custom domain with WAWS, you will need to log into your domain registrar’s system and make three changes. I’ll go into detail on these as we progress through this post, but in a nutshell, these steps are:
- Add an A record that points to the IP address listed in the Azure portal.
- Add a CNAME record called “awverify” that points to awverify.sitename.azurewebsites.net.
- Add a CNAME record called “www” (or modify the existing “www” CNAME) and point it to sitename.azurewebsites.net.
It’s pretty easy and you don’t have to be a super geeky tech person like the guy on the right side of this page to do all of this. Let’s go through these steps one-by-one. In the examples that follow, I’m going to redirect my custom domain SurfaceForWindowsRT.com to my WAWS site called MyCoolWAWSSite.azurewebsites.net. My domain is registered with GoDaddy. The steps are the same for other domain registrars, but the user interface will be a little bit different.
At the bottom of this post, you can see my entire DNS zone file with all of the necessary entries.
Step 1: Add an A Record
After I log into my domain at GoDaddy, I can edit my DNS Zone File. (There’s a “DNS Zone File” button that takes you to the right place on GoDaddy’s site. Your registrar’s procedure might be a little bit different.) As you can see in the image below, there’s an A record with a hostname of “@” and it points to an IP address. I need to change that IP address so that it matches the one in the Azure portal.
To find the IP address I need to use, I can log into the Azure portal, select my website, and then click on the Configure tab. If I scroll down on that page, I’ll see a green “Manage Domains” button, and when I click that, I can see the IP address that I need to use. As you can see below, the IP address I need to use for my A record is 220.127.116.11. (You will need to use the IP address displayed for your particular site.)
In the image below, you can see that I’ve changed the original A record and it’s now pointing to the IP address that the Azure portal gave me. Step 1 done!
Step 2: Add an awverify CNAME Record
In order to WAWS to use my naked domain (SurfaceForWindowsRT.com), I need to add a CNAME record called awverify that points to awverify.mycoolwawssite.azurewebsites.net. In the image below, you can see that I’ve added this entry in the CNAME section of my zone file at GoDaddy.
Once I’ve added this CNAME entry (along with the A record entry in step 1) and saved the changes, I can add my naked domain (without the “www” prefix) in the Manage Domains dialog in the Azure portal. One catch! You do have to wait for your changes to replicate across the Internet. In most cases, you can add your domain within a few minutes, but it might take quite a bit longer in some cases.
In the image below, I have added my naked domain to my website in the Azure portal. Notice that I get a green check meaning everything’s verified.
Once I add that, I can browse to http://surfaceforwindowsrt.com and it will bring up my site at http://mycoolwawssite.azurewebsites.net. (Folks who browse to http://surfaceforwindowsrt.com won’t even be aware that the site is hosted on WAWS.) However, I also want to use http://www.surfaceforwindowsrt.com, so I now have to add the second CNAME record for the “www” subdomain.
Step 3: Add a www CNAME Record
Most registrars are going to have a www CNAME already added for your domain. In those cases, you’ll want to edit the existing CNAME and point it to your WAWS URL. As you can see in the image below, my domain hosted at GoDaddy has a CNAME record for www that points to “@”. I need to edit that entry and change the “@” to point to mycoolwawssite.azurewebsites.net.
In the image below, you can see that I’ve edited the existing www CNAME entry for my domain and it now points to mycoolwawssite.azurewebsites.net.
Again, I have to save this change and allow it to propagate throughout the Internet’s DNS system before Azure will recognize it.
Step 4: Add Your Domains in Azure
Okay, I admit it. I lied a little. There’s a fourth step. After you configure all of this, you will need to add your custom domain entries to your website in the Azure portal. In step 2, I did that for the naked domain, SurfaceForWindowsRT.com. Now that I’ve added the www CNAME entry, I can add www.SurfaceForWindowsRT.com to my WAWS site in the Azure portal. The image below shows that entry.
As promised, here is my completed zone file at GoDaddy showing the three changes I made in order to make all of this happen. I edited out the CNAME records that don’t apply to my website in order to make it more clear.
I hope that this helps to explain how you can easily add your custom domain to your WAWS site.