Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between "Web" website and other websites in Windows Azure?

Tags:

package

azure

When defining a web role I can specify sites under <WebRole><Sites> element. One of the sites can have a name "Web" and then I'm not required to specify physicalDirectory for it - instead the site contents will be copied into sitesroot folder and duplicate the contents of approot and inflate the service package.

So it looks like it's a no-brainer - I should name my site any other name than "Web" and specify physicalDirectory and it will work just fine and without duplication hence a smaller package.

Is there anything I gain by naming my site "Web"? Why would I want to name it "Web" given the negative consequences?

like image 299
sharptooth Avatar asked Aug 10 '12 07:08

sharptooth


2 Answers

The "Web" site is simply the new project you created or existing project you selected when adding a WebRole to your cloud project. So the WebRole's default site (Web) is directly mapped to that web project.

This simply means it will use the assembly of that project for the RoleEntryPoint (WebRole.cs). That's why the output of that project is used in the approot (this is where the RoleEntryPoint is executed) and in the sitesroot (the IIS website).

Now if you want to keep your package small, you can indeed create a dummy site that serves only for the WebRole.cs part, and have a real site besides that. This will create 3 'folders' when deploying to Azure:

  • approot => Very small directory containing the dummy site
  • sitesroot\0 => Very small directory containing the dummy site
  • sitesroot\1 => Your real site

What you'll want to do is play with the endpoints to make sure that the dummy site is not exposed by giving it an internal endpoint:

  <WebRole name="MyWebRole" vmsize="Small">
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="Endpoint1" endpointName="DummyEndpoint" />
        </Bindings>
      </Site>
      <Site name="RealWebApplication" physicalDirectory="..\MvcApplication1">
        <Bindings>
          <Binding name="Endpoint2" endpointName="RealEndpoint" />
        </Bindings>
      </Site>
    </Sites>
    <Endpoints>
      <InputEndpoint name="RealEndpoint" protocol="http" port="80" />
      <InternalEndpoint name="DummyEndpoint" protocol="http" />
    </Endpoints>
    ...
  </WebRole>

And your dummy web application will look like this:

enter image description here

like image 181
Sandrino Di Mattia Avatar answered Nov 15 '22 06:11

Sandrino Di Mattia


Many months later I can't find any problems with changing the site name to anything except Web and explicitly specifying the physicalDirectory. It just works.

It just looks like Azure tools defaults are unreasonable. My .cspkg got smaller, so it takes less to prepare and less to unload and I waste much less time. I wish I found this earlier.

like image 43
sharptooth Avatar answered Nov 15 '22 07:11

sharptooth