I currently have an Azure cloud service with a web role (so it's a virtual machine with IIS installed on it). This web role currently runs an unique web application (WebAPI project).
What I'm trying to do is to create a new web application, but I need it to run on the same web role (i.e. two applications on the same virtual machine) to reduce the costs. I know it's possible (both web application will then run on the same IIS instance, on the same machine, with different ports) but I can't find resources about how to do it with a recent version of the Azure SDK.
I found great resources :
- Multiple site strategy on web role(s) and cloud service(s)
- https://michaelcollier.wordpress.com/2013/01/14/multiple-sites-in-a-web-role/
- http://www.wadewegner.com/2011/02/running-multiple-websites-in-a-windows-azure-web-role/
- http://blog.elastacloud.com/2011/01/11/azure-running-multiple-web-sites-in-a-single-webrole/
but all are a bit old (<= 2013) and don't apply anymore.
I'm currently using the Azure SDK 2.6. I've tried modifying my ccproj file (Cloud Service project file) so both WebAPI project share the same RoleName
:
<ProjectReference Include="..\MyProject1.csproj">
<Name>Website</Name>
<Project>{...}</Project>
<Private>True</Private>
<RoleType>Web</RoleType>
<RoleName>MyRole</RoleName>
</ProjectReference>
<ProjectReference Include="..\MyProject2.csproj">
<Name>Website</Name>
<Project>{...}</Project>
<Private>True</Private>
<RoleType>Web</RoleType>
<RoleName>MyRole</RoleName>
</ProjectReference>
This doesn't work, the "roles" node of my project within Visual Studio shows an error ("no project associated [project 2 name]
).
I've also tried to modify my ServiceDefinition.csdef
file:
<WebRole name="xxxx.Frontend.Azure" vmsize="Small">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
<Site name="AnotherWeb" physicalDirectory="foo">
<Bindings>
<Binding name="Endpoint2" endpointName="Endpoint2" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="8080" />
<InputEndpoint name="Endpoint2" protocol="http" port="8090" />
</Endpoints>
</WebRole>
No luck either.
How should I proceed?
EDIT :
Here's my current csdef file with modification for multiple sites support:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="AzureCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<WebRole name="XXX.YYY" vmsize="Small">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
<Imports>
<Import moduleName="RemoteAccess" />
</Imports>
</WebRole>
<WebRole name="XXX.ZZZ" vmsize="Small">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
<Site name="ZZZ" physicalDirectory="..\..\..\XXX.ZZZ\azure.publish">
<Bindings>
<Binding name="Endpoint2" endpointName="Endpoint2" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="8081" />
<InputEndpoint name="Endpoint2" protocol="http" port="8090" />
</Endpoints>
<Imports>
<Import moduleName="RemoteAccess" />
</Imports>
</WebRole>
</ServiceDefinition>