4

Goal:This is all about paying for one WebRole instance but demoing/testing multiple sites what are completely independent VS projects (ASP MVC 5, but this must not matter). Sites are differentiated not by port number instead domain (host) name)

Maybe I want too much, but this can be easily done using IIS by configuring IIS sites by host name (or IP, or port).

I understand (and can accept) that restriction, that these different VS projects must exist together in a VS solution, and can not deployed independently, I suppose a common Azure project exist which contains all configuration metainfo.

Tools: VS 2013 (Premium) and Azure tools 2.2

Now I have a solution with 2 projects in it: MySite (an ASP MVC 5 project) MySite.Azure

I would like to add a 2nd MVC project, and would like to modify config and other files in MySite.Azure to deploy both MySite and MySite2 and I would like to assign different hostname s to MySite and MySite2. (I do know how to assign my hostnames to my Azure IP using my DNS provider, please suppose that's already done)


If differentiating by host name is not possible, still is it possible to differentiate by port number?

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
g.pickardou
  • 32,346
  • 36
  • 123
  • 268

1 Answers1

6

Just to start from the top

You don't need all projects in a single solution but it does make it easier, so I will assume you will at this stage.

Add in your second project to your solution.

On your Azure project (MySite.Azure), on the Roles folder, Right Click and press Add > Web Role Project In Solution and add in the other project to your Azure project.

Next in your ServiceDefinition.csdef in the section

<Site>
   <Site name="Site1" physicalDirectory="C:\Users\User\Documents\Visual Studio 2012\Projects\Project1">
    <Bindings>
      <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="domain1.com" />
      <Binding name="Endpoint2" endpointName="Endpoint2" hostHeader="domain1.com" />
    </Bindings>
  </Site>
  <Site name="Site2" physicalDirectory="C:\Users\User\Documents\Visual Studio 2012\Projects\Project2">
    <Bindings>
      <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="domain2.com" />
      <Binding name="Endpoint2" endpointName="Endpoint2" hostHeader="domain2.com" />
    </Bindings>
  </Site>
</Sites>
<Endpoints>
  <InputEndpoint name="Endpoint1" protocol="http" port="80" />
  <InputEndpoint name="Endpoint2" protocol="https" port="443" certificate="SSLName" />
</Endpoints>

This shows 2 endpoints as well for SSL usage.

Adam
  • 16,089
  • 6
  • 66
  • 109
  • 1
    Adam, thanks for the answer. As proof of the pudding is in the eating I am going to try this. Is this one role or two roles? Besides of course I'll pay as I go for CPU, bandwith etc, am I paying the _same_ as I have only one site? – g.pickardou Feb 15 '14 at 13:21
  • This configuration loads your site on every role you start up. So if you have 2 VM's running, both sites will be loaded on both VM's and load balanced across. So you are paying the exact same as just a single website. If you only load 1 VM, they are both loaded on 1 VM. However for the uptime SLA you need to have at least 2 VM's running. – Adam Feb 15 '14 at 13:24
  • OK, thanks understand. I've tried and deployed. Now I am getting "HTTP Error 503. The service is unavailable." regardless which host name I try even the IP or original myname.cloudapp.net – g.pickardou Feb 15 '14 at 14:29
  • 1
    Going to myname.cloudapp.net or the IP address won't work at all because each site is tied to a domain name and it is the only way to connect to it. I would check that your DNS is set correctly (having www.domain1.com as a CNAME to myname.cloudapp.net) The way to quickly test if it is working, is to go into your hosts file locally and enter in your www.domain1.com and point it to the IP address. Then you can locally test if it is a DNS issue first. – Adam Feb 16 '14 at 02:31
  • 1
    Adam, thanks it works like a charm. Btw I checked the DNS by pinging the host names to check if it resolves to the correct IP. The problem was the I used hostHeader="domainX.com" but entering it to the browser it automatically converted to www.domainX.com and that was not matched. Anyway thx again. – g.pickardou Feb 16 '14 at 15:38