Since the release of Azure Web Sites a few months ago, one of the main questions I’m asked pertains to users’ ability to direct traffic to their Azure Web Site using a custom domain name. I’ve found a way to achieve this (sort of). In this blog post you’ll learn how you can use your DNS provider’s administration panel to send traffic to your shared-instance Azure Web Site.
Now, I admit this isn’t a perfect solution. I also apologize to the network guys out there, because this is kindergarten-level trickery. My SEO friends will cringe, too. The problem I’m aiming to solve in this post, though, is in response to a question I had from a few people on Twitter and during demonstrations of the new portal’s web site features.
This is great, but I can’t use my domain names with it. If I can’t do that and I can’t do that while I’m working on a site for a client, do I have to upgrade to a reserved instance right away or is there something I can do while in shared mode to get traffic using a custom domain name?
Ideally, you could set up some sort of redirection (301 or otherwise) to get traffic to your site using your domain management tool of choice, get some traffic, and then make (or obtain) a small investment in upgrading to a reserved instance once things are up and running. Given the free opportunity Microsoft is offering, you’ve got 10 chances to build one site for free for a year. The chances at least 1/10th’s of your web site ideas are going to make you enough to pay for a small reserved instance is pretty good, right? If not, or if you’re cool with redirection and just have some silly sites or fun little ideas you want to show off, you can use this domain trick as long as you can stand knowing it’s all really just a clever domain redirection illusion .
I’m a user [and huge fan] of DNSimple.com for domain management, so I’ll be demonstrating this trick using their administration panel. Your domain management provider probably has something similar to DNSimple.com’s URL record type (I think it’s a 301 redirect under the hood, but don’t quote me on that). The idea here is this – DNSimple will send traffic that comes to YourCustomDomain.com to YourCustomDomain.azurewebsites.net. Let’s set this up and get some traffic coming in!Create Your Own Azure Web Site
First thing is your web site itself. Go to WindowsAzure.com and set up a free account to give yourself a year of playtime with 10 free sites . Once you’ve logged into the portal, create a new web site. One with a database, use the application gallery, whatever you choose. This demo will allow for the creation of a simple site, but you’ll then switch over to DNSimple’s administration panel to set some DNS settings. In a few minutes you’ll have a live site, and a live domain name, that directs traffic to your shared-instance Azure Web Site.
Once you’re in the portal just select New, then Web Site, then Quick Create, then give it a URL prefix you’re comfortable using. In this case I have a domain named NimbleSquid.com, and I’ll use the domain name nimblesquid.azurewebsites.net when I create it in the portal.
Once the site is finished creating it will appear in the list of web sites you have hosted in Azure.
When you click on that site to select it and click the browse button you’ll see the Azure Web Sites domain name, with the custom prefix you provided to create the site.
Setting up a URL Record using DNSimple.com
I don’t know if other DNS providers call their redirection records “URL” the way DNSimple.com does, but if not, your provider probably has something like a 301 redirect. That’s sort of the idea here, we’re just going to redirect traffic permanently to a *.azurewebsites.net domain whenever a request is made to the real domain name. For NimbleSquid.com, no records exist, so the DNSimple.com advanced editor for this domain has no entries.
Likewise, if I try to browse to the custom domain name, I’ll get an error page. That’s pretty much expected behavior at this point; DNSimple.com’s DNS servers basically don’t know where to send the request.
Click on the Add Records button, then select the URL option from the context menu. You’ll then see the screen below. You can choose to put in a CNAME prefix here, or just leave it blank. In the case of the screenshot below, any requests made to any CNAME of nimblesquid.com will be directed to the nimblesquid.azurewebsites.net domain.
Setting the TTL menu to 1 minute will result in the domain name resolving (or redirecting) to your Azure Web Site just a moment or two after you click the Add Record button. Now, when users make a request to your custom domain name, they’ll land on your Azure Web Site. Granted, this is a trick, as it just does a redirection, but if you’ve got a site on Azure Web Sites and you’ve got a custom domain you want to use with that site, and you aren’t ready or can’t yet afford to upgrade to a reserved instance, this could get you through in the meantime. You can get your site up and running, set up the redirection, and start taking orders or showing off your skills on your blog.