3

What's the best practice to deploy multiple Web site on Cloud Service ?

I have three web sites, is it possible to deploy those three web sites into one Cloud Service ? (Three instances in one Cloud Service)

Or Do I have to create three Cloud services and deploy each web site separetly ?

Thank you

My ServiceDefinition file:

  <WebRole name="WebRoleName" vmsize="ExtraSmall">
    <Sites>
      <Site name="Web" physicalDirectory="../WebSite1">
        <Bindings>
          <Binding name="Endpoint1" endpointName="Endpoint1" />
        </Bindings>
      </Site>
      <Site name="Web2" physicalDirectory="..\..\..\WebSite2">
        <Bindings>
          <Binding name="Endpoint2" endpointName="Endpoint2" />
        </Bindings>
      </Site>
    </Sites>
    <Endpoints>
      <InputEndpoint name="Endpoint1" protocol="http" port="80" />
      <InputEndpoint name="Endpoint2" protocol="http" port="81" />
    </Endpoints>
    <Imports>
      <Import moduleName="Diagnostics" />
      <Import moduleName="RemoteAccess" />
      <Import moduleName="RemoteForwarder" />
    </Imports>
  </WebRole>
</ServiceDefinition>

By using that code, WebSite1 is available and WebSite2 is not, even by adding :81 I used the Remote Desktop to validate the deployment on IIS, and I saw that WebSite1 was correctly deployed but WebSite2 was not. WebSite2 and WebSite2.Test were two folders deployed below the Virtual Website Directory. By Copying manually the content, of the WebSite2 folder, below the Virtual WebSite Directory, i was able to access to my website via http://ID.cloudapp.net:81

What's the error ? Why the Test project is also deployed for WebSite2 ? (I made a check on the depedency and that's not selected)

Thank you

fix105
  • 234
  • 1
  • 6
  • 16

2 Answers2

2

You could do either way. It really depends on what you need to do. If you want to host all your websites on port 80 under the same url for example:

http://www.mywebsite.com/site1
http://www.mywebsite.com/site2
http://www.mywebsite.com/site3

then you can try this:

http://kellyhpdx.wordpress.com/2012/04/11/deploying-multiple-web-applications-to-a-single-azure-instance-and-applying-web-config-transforms-correctly/

Alternatively if you don't necessarily need this implementation and you can host your websites under different ports, then you could create one instance under a separate role.

You could even have 1 cloud project per webrole, for instance if you wanted to have a test admin website to control your project, which shouldn't be included in production, you could have 2 cloud projects: 1 with all the production instances and 1 with your test admin website that you deploy as and when needed.

dqm
  • 1,190
  • 3
  • 12
  • 19
  • Thank you for your answer. Once I have deployed my web sites, how can i access it ? I have one Cloud Services (first in staging mode): Http://IDNumber.cloudapp.net, how can i access to the Web Site 1 and Web Site 2 ? – fix105 Mar 06 '13 at 13:33
  • After you implemented the solution described above correctly, you should have Http://IDNumber.cloudapp.net/WebSite1 and Http://IDNumber.cloudapp.net/Website2 and they should also appear under the same (Default Website) in IIS on that server as different applications – dqm Mar 06 '13 at 16:01
  • I have got an error but i don't know how to identify the error message. As it was in RemoteOnly, I will change my configuration file to receive more information. Did I correctly understand: I have to use Port or HostHeader. If i want to use a HostHeader for the WebSite2 (which is the plan), i also have to define a HostHeader for WebSite1 ? That's not possible to let the Default URL for WebSite1 ? – fix105 Mar 06 '13 at 16:19
  • So, if you decide to have 1 cloud project to host to **different** web roles, then these two should use different port numbers, configured in your csdef file. If you decide to host them under the same website, you should end up with the implementation I described. You shouldn't have to do any HostHeader jiggery-pokery. – dqm Mar 06 '13 at 16:27
  • I had an issue in my folder structure. Now, everything have been deployed correctly. Thanks for your help – fix105 Mar 07 '13 at 13:36
0

You'll have to manually modify the .csdef file for your Azure project to add multiple sites into the cloud service. Wade Wegner posted a good article on how to do so. Note that each site must have a unique host header.

Evan
  • 5,925
  • 6
  • 33
  • 35