Multiple sites in one role with different config

Answered Multiple sites in one role with different config

  • Thursday, May 31, 2012 10:02 AM
     
     
    I want to deploy same web application to multiple sites, I read this http://www.wadewegner.com/2011/02/running-multiple-websites-in-a-windows-azure-web-role/ but my questions are:

    1) How can I have different web.config for each site, eg. for different connections strings and other keys that change from site to site.

    2) how can i add more sites to role when the role is publish.

All Replies

  • Thursday, May 31, 2012 12:21 PM
     
     

    Hi Cristian,

    1) I think, that each project have its own web.config when you deploy it, so different connection strings can be in each web.config.

    2) You have to add site in your windows azure project and redeploy it.

    Maybe there is a better workaround there. I have never been using multiple website per role. So, wait a while if somebody give you better solution for this.


    Microsoft Platform Developer Cloudikka blog

  • Thursday, May 31, 2012 12:42 PM
     
     

    Regarding 1st point, each website will have its own web.config. There is another configuration file(.cscfg)  which comes with Azure project. For more details, check out the link: http://www.structuretoobig.com/post/2010/02/22/Azure-Miniseries-3-ServiceConfig-vs-webconfig.aspx

    Regarding creating websites at run-time after the role is published, have a look at the link: http://www.toolheaven.net/post/Azure-and-creating-website-dynamically.aspx Though, I haven't tried it yet, but I think it should work for you. And regarding the content of the website, I think you can import from the blob storage.

     

    I hope it helps!! If you found this post useful, Please "Mark as Answer" or "Vote as Helpful". Thanks! Vaibhav Gujral.


  • Thursday, May 31, 2012 4:12 PM
     
      Has Code

    In my ServiceDefinition.csdef have this:

     <Sites>
          <Site name="Web">
            <Bindings>
              <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="www.storeA.com" />
            </Bindings>
          </Site>
          <Site name="Web2" physicalDirectory="..\MyWebRole">
            <Bindings>
              <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="www.storeB.com" />
            </Bindings>
          </Site>
        </Sites>

    And in my ServiceConfiguration.cscfg this:

    <Setting name="DB1" Value="Data Source..." />
    <Setting name="DB2" Value="Data Source..." />

    How can i set www.storeA.com use DB1 and www.storeB.com use DB2? checking the url?

    Not only for settings, eg how can load different css file for each site?



  • Thursday, May 31, 2012 4:31 PM
     
     

    You can set the connection string in your application code.

    See if this helps: http://stackoverflow.com/questions/5979562/set-the-application-connectionstring-in-the-service-configuration-instead-of-web


    I hope it helps!! If you found this post useful, Please "Mark as Answer" or "Vote as Helpful". Thanks! Vaibhav Gujral.

  • Friday, June 01, 2012 8:52 AM
     
     Answered

    This is the solution for all my questions Building a Scalable, Multi-Tenant Application for Windows Azure.

    Thanks for your help.