Configure Custom Domain Names in 4 Easy Steps

Microsoft Azure Web sites provide a robust and easy-to-use container for hosting your Web applications. This doesn't just pertain to ASP.NET apps, but to several templates such as Drupal, WordPress, Orchard and so on. The service also provides first-class support for Node.js Web apps/APIs, PHP and Python. If you're new to Azure Web sites, you might think, "Big deal, this is just another Web host." You would be wrong. There's a ton of value you get with Azure Web sites that blows away your commodity Web hosters:

  • The free version lets you 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 six instances/nodes along with enabling Web Jobs that provide worker processes for executing jobs on a schedule, continuously or on-demand.
  • The standard version lets you dedicate not just instances, but full VMs to your application and supports auto-scaling your app based on metrics and triggers.

There's a lot more to Azure Web sites, whether you're a .NET, Node.js, PHP or Python developer. Learn more at the Azure Documentation page.

When you create your Azure Web site application, you get both an IP and URL. The URL takes the form of [your app] Chances are you'll want your own domain name so that instead of [your app], you can point to a specific address. You can do this in four simple steps.

Step 1: Ensure your site is configured for shared or standard mode. The free version doesn't support custom domains, which seems reasonable. If you started with a Web site in free mode, simply click on the Scale option and choose Shared or Standard mode and click OK.

Step 2: Copy the IP and Azure Web site URL. The next step is to make note of your URL and IP address. You'll need this for the third step in this process. Go to the list of Azure Web 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] and your IP.

Step 3:Update the A Record and CNAMEs. Make a note of each and log in 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 whichever console lets you configure your A Record and CNAMEs. These records allow for requests to your registered domain name to be forwarded to Azure specifically your Web site's host name. The result is your Web site will resolve to both [your app] and whatever domain you purchased.

The A record needs to point to the IP address you captured in step two. Replace whatever value is there with the IP address provided. When someone calls up your site, your registrar will authoritatively answer that request and pass it on directly to the IP address you provided. For the CNAME, there are three entries you need to make:

  • Point www to [your app] -- This tells DNS that [your app] should be the destination (canonical host) for any DNS queries that begin with www (like your site).
  • Point awwverify and awwverify.www to awwverify.[your app] -- This provides for a DNS validation mechanism so your Azure Web site can validate that your domain registrar has been configured to allow the Azure Web site to serve as a canonical domain in the event that a CNAME lookup 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 Web site again. This time, enter your new domain name. If you want the Azure Web site to respond to both www.[yoursite].com and [yoursite].com, you'll want to create both entries. You'll likely see a red dot indicating that validation and/or CNAME lookup has failed.

This is simply the way the Azure Web site tells you records have not yet propagated. You can happily continue using your Azure Web site using the [your app] URL. When you come back to the dialog, the verification should succeed and any request for [yoursite].com should automatically resolve to your Azure Web site app.

Rick Garibay is a developer, architect, writer and speaker. He's passionate about distributed technologies and application lifecycle management and is currently a distinguished engineer at Neudesic.

Posted by Rick Garibay on 04/15/2015

Keep Up-to-Date with Visual Studio Live!

Email address*Country*