Hundreds of subdomains dynamic mapping to Azure

Answered Hundreds of subdomains dynamic mapping to Azure

  • Saturday, August 11, 2012 6:28 PM
     
     

    I'm building SaaS solution that gives our clients possibility to build online landing pages. The service provides tools to build and hosts landing pages. We need to give our clients option to connect their own domain names to the pages they built. Let say the service domain is www.abc.com used for Azure. Every client has local URL www.abc.com/client. However, usually clients want to be able to use own domains like www.client.com instead of our local URL. Of course we can instruct them to add  CNAME that points www.client.com to our Azure site. The problem is that Azure also requires to add every domain manually:


    Is there a solution to pass this stage some way? Let's say we'd know the clients domains asking them to provide the domains in their profiles. How could we supply the domains to Azure dynamically and not manually? This is the question. Having at least 100+ clients make manual entry impossible. I'd appreciate any recommendations and solution to make it work.




All Replies

  • Saturday, August 11, 2012 7:26 PM
     
     
    See also http://stackoverflow.com/questions/11898378/using-dynamic-domain-mapping-in-windows-azure.
  • Saturday, August 11, 2012 7:30 PM
     
     
    Yep. Thanks. You pointed me to my question I asked there. Unfortunately, you did not provide solution in your answer here or there.

    Michael Babich

  • Saturday, August 11, 2012 7:53 PM
     
     

    Hi Michael,

    According to this recent similar thread in the forums, at this moment there isn´t a Management REST API for Windows Azure Websites nor Powershell commands.

    You can vote for this feature here: http://www.mygreatwindowsazureidea.com/forums/34192-windows-azure-feature-voting

    Hope this helps!


    Cheers, Carlos Sardo

    • Proposed As Answer by Carlos Sardo Saturday, August 11, 2012 7:53 PM
    • Unproposed As Answer by Michael Babich Saturday, August 11, 2012 8:05 PM
    •  
  • Saturday, August 11, 2012 10:03 PM
     
     
    Guys, thanks for comments! But I look for a solution. Posts like "I do not know how to do it, that is why it is probably impossible" are not an answer. Thanks again. I'd appreciate any solution how to workaround Azure shortcomings. May be using in the process some third party services or rerouting at some point somewhere and benefiting from Azure advantages, but deliver via other service.

    Michael Babich

  • Monday, August 13, 2012 5:49 AM
     
     

    The referenced thread doesn't say anything like "I do not know how to do it, that is why it is probably impossible." It says that there is no documented API for managing Windows Azure Web Sites. We know there's an undocumented API, since it's used by the Node.js CLI, but the CLI doesn't support registering CNAMEs, so you're not going to find help there.

    There are probably other ways to accomplish what you're trying to do, but we'd need to know something about your app and its requirements to suggest them. For example, you could just use a Cloud Service with a web role instead of a Web Site, but we have no idea if that would meet your needs, since we don't know what those needs are.

  • Monday, August 13, 2012 6:50 AM
     
     

    I have couple of questions here,

    How are you onboarding your tenants to your application?

    Will you create any new virtual directory for each tenant? (Since you mentioned your clients get local URL www.abc.com/client).



    Please mark the replies as Answered if they help and Vote if you found them helpful.

  • Monday, August 13, 2012 12:18 PM
     
     

    1) Users register, compete profile, create page, choose local address for the page ( www.abc.com/client ) and may enter their domain to use. So we can get information as to what domain associate with which page.

    2) Right now the project in on LAMP server and every page has virtual folder www.abc.com/client


    Michael Babich

  • Monday, August 13, 2012 12:30 PM
     
     

    If it is virtual folder, why dont you let the customer configure CNAME pointing to virtual folder root!

    However its going to be your azureportal/customervirtualfolder, which is not going to change.



    Please mark the replies as Answered if they help and Vote if you found them helpful.


  • Monday, August 13, 2012 12:45 PM
     
     
    Asking clients to change CNAME is not a problem. Also it is not a problem what folder content to provide based on request. Problem is that client's domain must be also provided to Azure some way for Azure to validate domain. There is picture in the question body of Azure management panel stating that we manually need to add each domain, associated with the service. Just changing CNAME does not work. We also need to provide some way client's domain to Azure. This is the problem.

    Michael Babich

  • Monday, August 13, 2012 1:26 PM
     
     

    Yah I got that. This is possible with web roles. We can specifiy the headers easily with webrole. But with web site i believe it's not exposed.

    I will see if we can workaround this problem and post back if I find anything



    Please mark the replies as Answered if they help and Vote if you found them helpful.

  • Monday, August 13, 2012 1:41 PM
     
      Has Code

    How I've done this is using a webrole, not a website.  You can create a default website for a website, so it will catch every webrequest which arrives at the instance.

    My service definition contains a "generic" endpoint:

     <Sites>
          <Site name="Web">
            <Bindings>
              <Binding name="Endpoint1" endpointName="Endpoint1" />
            </Bindings>
          </Site>
        </Sites>
        <Endpoints>
          <InputEndpoint name="Endpoint1" protocol="http" port="80" />
        </Endpoints>
    And it is my application which controls the output depending on the hostname.


    Dampee (blog | twitter)

  • Monday, August 13, 2012 2:00 PM
     
     
    DamPee, does Azure give access to your application from any domain with changed CNAME and no additional domain entering to Azure? No 404 page?

    Michael Babich

  • Monday, August 13, 2012 2:11 PM
     
     

    No, you still need to add host headers to the end points. With web roles you can do it through management API.

    You can refer to this article for how to run multiple web sites with one azure web role.

    Video for the same



    Please mark the replies as Answered if they help and Vote if you found them helpful.

  • Monday, August 13, 2012 2:19 PM
     
     
    Veerendra, thanks. Do you think this solution would be suitable for thousands of addresses?

    Michael Babich

  • Monday, August 13, 2012 2:26 PM
     
      Has Code

    Michael,

    That's right.  IT IS NOT NECESSARY TO SET HOST HEADERS. Just use the Service definition as put above.

    I accessed my hostname as follows in my initialiase of the MVC controller:

    protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); #region Get Current Domain Name _dnsName = Request.Url.DnsSafeHost; _dnsName = _dnsName.Replace("www.", ""); Trace.Write("m_dnsName: " + _dnsName); #endregion if (dc.Domains.Any(d => d.Name == _dnsName)) { // do stuff for particular domain } else { Response.Clear(); Response.StatusCode = 404; Response.Write("No domain found: " + _dnsName); Response.End(); }
    }

    Maybe a small disclaimer.  I'm working on sdk 1.6 and I haven't updated it to the latest June SDK yet. But i guess that there won't be any changes for that.  :-)

    Of course using a web role has the disadvantage that you can not use FTP or GIT deployment.  If you are running a big SAAS app, that's not a concern in my opinion.  You WANT to deploy to a staging environment.  And be sure that everything is running before moving to staging.  FTP and GIT just gives to much freedom to do quick (and stupid) fixes. 

    If our app is deployed to staging, I update the local HOSTS file so that the real domain names are tested against the the staging environment.  If everything runs well, I do the VIP swap. 


    Dampee (blog | twitter)

  • Monday, August 13, 2012 2:52 PM
     
     
    Veerendra, you are incorrect.  It is not necessary to add host headers to endpoints.

    Dampee (blog | twitter)

  • Monday, August 13, 2012 3:44 PM
     
     

    Dam, thats the custom solution you proposed. For that matter we can implement custom solutions in many ways. You mentioned one of them.

    Michael is interested in the using the capabilities provided by platform. Conceptually headers are required to be mapped when playing with OOB capabilities.

    There is a very nice documenation, pros and cons written here.



    Please mark the replies as Answered if they help and Vote if you found them helpful.

  • Monday, August 13, 2012 3:58 PM
     
     Answered

    Michael, practically it is possible to scale for the number of addresses. There is a nice analysis on creating multi tenant applications on azure. Please refer to this link.

    Just go to Segment Web site Tenants by Host Headers section for the same.

    There is a video on windows azure accelator for web role you can find here. it provides an example. Also another video you might want to go through.

    Hope it helps.



    Please mark the replies as Answered if they help and Vote if you found them helpful.

    • Marked As Answer by Michael Babich Monday, August 13, 2012 6:44 PM
    •  
  • Monday, August 13, 2012 4:05 PM
     
     

    My apologies.  I understood from your reply that you are obligated to put in host headers, which is not the case

    I have never tried binding thousands of domainnames to a single website instance. There doesn't seem to be a real maximum.  The only reference I found on the possible maximum number of bindings on a single server is this post on serverfault.

    The article you provided is very good indeed.


    Dampee (blog | twitter)


    • Edited by DamPee Monday, August 13, 2012 4:06 PM typo
    •