Search code examples
azureasp.net-mvc-4subdomainazure-web-roles

Testing subdomains in Azure staging


I just added a new area to my MVC application hosted in an Azure Web Role that uses Attribute Routing to hit subdomain controllers for routes with subdomain prefixes. On the azure emulator this works great and I can hit the correct controllers using my development url (for which I have a record in the host file)

host file record: 127.0.0.1 domain.com portal.domain.com

working subdomain route: http://portal.domain.com:81/SubController/SubAction

How can I continue to test this in a staging environment? At the moment I'm using the 3-month free trial and I understand I can't add a CNAME or A record until I start paying but I still have 2 months in the trial and simply want the application to WORK. It doesn't have to look pretty I don't care if the subdomain url looks like this:

  http://portal.8c72d21eg2c14636s0542f181024e72a.cloudapp.net/

This currently throws:

 [Fiddler] DNS Lookup for "portal.8c72d21eg2c14636s0542f181024e72a.cloudapp.net" failed. No such host is known 

Is there a way?


Solution

  • First, as you already noted, there is no limitation for CNAME against Cloud Services.

    Secondly, I will strongly suggest using production environment even for testing/staging purposes, especially when developing / testing. The only difference between a Cloud Service staging and production environments is that you get a fixed/stable domain name for your production environment (i.e. mygreatapp.cloudapp.net), while you always get a different GUID-like domain for staging with every deployment (i.e. 8c72d21eg2c14636s0542f181024e72a.cloudapp.net). Other than that, everything is the same - billing, networking, resources, everything.

    Given the specifics, you understand that you have to create a new CNAME every time you deploy a new version (if you deleted old staging) to staging, because you will be given a new GUID-like domain.

    So, create your cloud service, CNAME your domain to its domain, deploy to production slot and live happily ever after ;)