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?
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:
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With