|By Adam Hoffman||
|October 3, 2012 12:15 PM EDT||
I was meeting with a small company today that has developed a SaaS solution around task and project management. It's a very cool application, and as is the fashion these days, uses subdomains to determine the end user's company as requests come to the browser. So, if I were to sign up for the application, my home url would be http://adamhoffman.getdonedone.com, whereas if you signed up (and had the unlikely name of Bill Ion), your home page would be http://billion.getdonedone.com. This is handled in ASP.NET application code on their Win2K8 servers hosted at Rackspace. The question quickly became "hey, we can do something similar in Azure, right?"
The answer is yes, and no, and yes. Let me explain.
My instant assumption was "yes", and ultimately, it is true that you can accomplish this behavior. It does, however, require that wherever you host your DNS that points to your application supports the concept of "wildcard DNS records", and more specifically, supports "wildcard CNAMEs". As it turns out, Go Daddy's DNS services don't support this, so we'll have to look elsewhere to get this functionality.
The next question you might be asking yourself now is why do we care about wildcard CNAME versus just wildcard DNS? Specifically, the answer lies in the way that Azure provides you high reliability. As a very quick DNS primer, you need to understand the difference between A records and CNAME records. Go read the link if you want the details, but the short answer is "A records point to IP addresses, CNAME records are aliases of other domain name records. OK, but why does this matter?
Well, as it turns out, when you want to put your fancy brand on your Azure based website, you can only do that by way of a CNAME record. The reason that you can't use an A record to point to your site is that your site doesn't have an IP address. Well, it does, but it's not something that you can get access to, and even if you could, it's not persistent, and will likely change. In order to avoid this problem, what you get is really a domain name that is a part of "cloudapp.net". For example, the website that I'm about to demo for you that supports wildcard subdomains is addressable by way of "wildcardsubdomain.cloudapp.net", but not by IP address. Well, OK, yes, smarty pants. It is addressable by IP as well. For example, at this moment I can also get to the same site at http://22.214.171.124, but I shouldn't rely on it. Who knows - by the time you read this, it might not work at all. If you want to know how I figured that out, check out nslookup.
The reason that's all true is that Azure relies on CNAME so that it can switch your IP around, but keep your site addressable. Why does it do it? It's mad network stuff related to load balancers, and the Azure Fabric controller, and it's done to ensure that your site has the maximum stability and uptime.
Okay, back to the problem at hand - getting our dynamic subdomains passed through to our application code to allow for multitenant applications split by the third level domain. How will we handle it? Here we go.
- First, we'll find a DNS service that supports wildcard CNAMEs.
- Next we'll configure that DNS service to point to our application.
- Finally, we'll write the application code that understands the incoming requests so that we can fork our clients appropriately.
- After finally, we'll take a look at the URL Routing features of ASP.NET and see if we can extend our example to integrate nicely with it.
On the first count, it's not actually as straightforward as you might think. For example, I've used GoDaddy to procure several of my domains (yes, I am aware of the SOPA thing, and won't get political here). As the link here reveals, wildcard CNAMEs aren't an option in GoDaddy's DNS servers, so we'll need to look elsewhere. I won't attempt to put together an exhaustive list here, but one DNS service that does support this concept is Amazon's Route 53 DNS service. Another nice feature of this is that it has an API, which actually opens up another possibility if we so chose. Our solution here to route all subdomains to a single hosted web site. An alternative to our multi-tenant single application approach would be to actually specifically provision subdomains and point them to different hosted web sites. So, instead of
*.adamhoffman.net CNAME wildcardsubdomain.cloudapp.net (which has application code that sorts it out)
we could, instead go with
customer1.adamhoffman.net CNAME customer1.cloudapp.net (which is for the customer1 domain), and
customer2.adamhoffman.net CNAME customer2.cloudapp.net (which is for the customer2 domain), and
Yes, we could do that, and with the Route 53 API, we could even provision those new CNAME records as necessary. But that's not the route we're going to use. We'd like to use the former option, and have a single wildcard CNAME record that just routes everything to our super smart application.
OK, so next, we'll get ourselves an Amazon account to set up our DNS services on Route 53. Once you've signed up, create, in Amazon's terminology, a hosted zone for the domain that we'll support wildcards on. Of course, you need to own this domain.
Take a look now at the "delegation set" that Route 53 has assigned you. There are 4 DNS servers listed here, and these are the DNS servers that you need to tell your domain registrar about so that it makes sure that requests for your domain are handed off to these Route 53 DNS servers. In my case, my registrar for adamhoffman.net is Go Daddy, so I'll use the Go Daddy tools to point to these DNS servers.
With all of this done, there's only one final step. We need to tell the DNS servers that handle adamhoffman.net that the canonical name (CNAME) for *.adamhoffman.net is really wildcardsubdomain.cloudapp.net. Look at the CNAME record for *.adamhoffman.net in the following picture. That's the secret sauce.
- Mainstream Business Applications and In-Memory Databases
- Findly Enhances Recruiting Efficiency With New Single Sign-on Portal
- Ukraine Has Potential in Midst of Chaos
- “Entisys 02” Finishes in Top 20 at the 2014 NASCAR K&N Pro Series West Race at the Sonoma Raceway
- Complete Surface Pro 3 Review - 3 days later
- Flexera Software Increases Commitment to Europe with Germany-based Datacenter to Host FlexNet Manager Suite Cloud for European Customers
- June 2014 Server and StorageIO Update newsletter
- CORRECTING and REPLACING Android and the Open Automotive Alliance Shift into the Next Gear
- Research and Markets: Global Industrial Control Systems (ICS) Security Market 2014-2018 with Cisco, Fortinet, General Dynamics, Juniper Networks, McAfee, Raytheon & Symantec Dominating
- MongoDB World in NY City this week
- Is Business Transformation a Dirty Word(s)?
- Book Review: Learning Mobile App Development
- Mainstream Business Applications and In-Memory Databases
- The Odd Couple: Marrying Agile and Waterfall
- FlexNet Manager Suite Wins CODiE Award for Best Asset Management Solution - 4th CODiE Award for Flexera Software
- Fanning the Flames of Agile
- Big Data, Cloud and Mobile - Converging Technology Trends
- April and May 2014 Server and StorageIO Update newsletter
- WSO2 Introduces Industry’s First Enterprise Identity Bus With the Launch of WSO2 Identity Server 5.0
- Big Data Expo 2014 Silicon Valley Call for Papers Now Open
- Jim Miller at ImageWare Systems, George Romas at HP, Jody Ross at AMAG, + March Networks and StrikeForce Featured in SecuritySolutionsWatch.com Interviews
- Microsoft SharePoint at a Crossroads – Opportunities & Challenges Abound
- The Butterfly Effect Within IT
- One Horizon Group Announces First Quarter 2014 Results
- Google Maps and ASP.NET
- Converting VB6 to VB.NET, Part I
- How to Write High-Performance C# Code
- Where Are RIA Technologies Headed in 2008?
- Crystal Reports XI & How It Has Changed
- Creating Controls for.NET Compact Framework in Visual Studio 2005
- Programmatically Posting Data to ASP .NET Web Applications
- Implementing Tab Navigation with ASP.NET 2.0
- AJAX World RIA Conference & Expo Kicks Off in New York City
- The Top 250 Players in the Cloud Computing Ecosystem
- i-Technology Viewpoint: "SOA Sucks"
- .NET Archives: Getting Reacquainted with the Father of C#