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.


7 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.

Bill S · 22nd April 2021 at 1:40 pm

This is very good to know.

I have quick question as it relates to Cost. Is the Cost of hosting more than one Site in a single Azure Web App Resource a Shared Cost or does it incur a New Cost?

Thanks!

    Shinigami · 22nd April 2021 at 2:43 pm

    You just pay for the single Web App and any sites that you having running under it share its resource pool. There’s no additional cost for hosting a new app in a virtual folder under the parent Web App, though obviously all apps will be consuming shared resources so you may need to scale up the parent Web App if you want to host a lot of sites.

      Bill S · 28th April 2021 at 9:39 pm

      Thanks. Makes perfect sense.

Leave a Reply to Arkadeep De Cancel reply

Avatar placeholder

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