Hosting multiple sites in one Azure WebApp

Sometimes it’s necessary to host multiple sites under the same parent address, in Azure this can be done by deploying multiple projects to seperate folders within a single WebApp.

To begin with you need to create a WebApp, once this has been created use the Console blade under Development Tools to create subfolders to host your sites. For example, my base site is datofy.azurewebsites.net and I want to set up two sites running on datofy.azurewebsites.net/portal and datofy.azurewebsites.net/xmp so within the Console blade I run “mkdir portal” and “mkdir xmp” to create the folders.

Once these have been created they need to be added as a virtual application within the Application Settings blade.

Once that has been done download the publish profile for the WebApp and edit a copy of it. Update the profile names for the web deploy and FTP sections to reflect the folder name and allow you to distinguish between publish profiles. The sections that need updating to allow you to publish to the virtual application are msdeploySite and both instances of destinationAppUrl, in all cases just add “/portal” (or whatever your folder might be called) to the end of the address, so http://datofy.azurewebsites.net becomes http://datofy.azurewebsites.net/portal.

After the publish profiles have been updated you can import them in the Visual Studio publish dialog and publish them.


Leave a Reply

Your email address will not be published. Required fields are marked *