问题
I am working on a Task Management System using VS 2010, WCF and Windows Azure. This is a simple personalized task management application. The application allows users to organize and share their task. There will be no. of Users in my project. If somebody “Subscribes” to the application, then we will need to create a “Space” for him with a Subdomain or “Subfolder. How can I implement sub domain mapping in windows azure. What is the real advantage of sub domain mapping?
Regards, Ranish
回答1:
Just to assist a bit on the other answers.
Azure's main mechanism for routing requests to your instance is to use "CNAME" DNS records - http://en.wikipedia.org/wiki/CNAME_record.
These CNAME records basically tell the clients (browsers) that www.mydomain.com is an alias for myapp.cloudapp.net
Sadly you cannot CNAME a wildcard Depending on your DNS host you may not be able to wildcard CNAME records (see https://serverfault.com/questions/44618/is-a-wildcard-cname-dns-record-valid), so in order to map multiple subdomains to the same Azure instance, then you may need to set up multiple CNAME records - one for each subdomain you want to reroute - i.e. when you sign up customer "new", then you need to add a new CNAME record mapping "new.mydomain.com" to myapp.cloudapp.net
The two suggestions from Joannes and jmac both suggest external services for setting up those mappings. For some other options - and some Amazon C# sample code - see this post http://computerone.co.nz/community/discussion/29/amazon-route-53-dns-request-in-c-using-the-rest-api/p1 (there's also an affordable C# library available on http://www.proactiveit.co.nz/Route53/R53Connect/)
回答2:
Being able of generating many subdomains linking to a Windows Azure web role is a matter of programmatic reconfiguration of a DNS rather than a matter of web role configuration.
Amazon offers a cloud-based DNS service named Amazon Route 53 that you could use for this purpose. It would work with Windows Azure actually.
Then, within your webrole, you would need to apply some ASP.NET tweaks to grab the host header of the initial web request to grab the actual subdomain being browsed by your users.
回答3:
We avoid the need to create a DNS CNAME record for each "Space" by using DynDns Custom DNS to create a wildcard CNAME record that routes all subdomain requests (*.ourdomain.com) to a web role. If you decide to go this route, your web role will parse out the subdomain of the incoming request to lookup a user's "Space".
From the DynDns documentation:
Alias (CNAME) Records
CNAME records alias one host name to another. For example, many customers alias www.domain.com to domain.com; this ensures that both www.domain.com and domain.com are always assigned to the same IP address. CNAME records in Custom DNS take the following options:
As with host (A) records, the Hostname field is restricted to allow only the characters A thru Z, the digits 0 thru 9 and the hyphen (-). The Hostname field can use an asterisk (*) to generate a wildcard CNAME record. (The Hostname field cannot be left blank, as RFCs prohibit second-level CNAME records.)
来源:https://stackoverflow.com/questions/6120172/sub-domain-mapping-in-windows-azure