Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
476 views
in Technique[技术] by (71.8m points)

package - What's the difference between "Web" website and other websites in Windows 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 => Very small directory containing the dummy site
  • sitesroot1 => 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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...