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.


4 Comments

adam · 12th February 2019 at 9:35 am

thanks, they don’t really advertise this do they…

    Scott · 18th March 2019 at 3:48 pm

    They don’t advertise the best practice on the vast majority of Azure from my personal experience. Thankfully there are blogs like this where the community helps.

Arkadeep De · 20th August 2019 at 5:56 am

Can I use sub domain for this. Like instead of /portal can we have portal.website.com??

    Shinigami · 20th August 2019 at 9:09 am

    You can use a sub-domain with the web app but then all sites under it will use that sub-domain. I don’t believe there’s a way to use different sub-domains for different virtual folders.

Leave a Reply to Shinigami Cancel reply

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