The Case of Multiple Site Hosting

Kaas Plateau : Shot on Sony a6000, SEL55210 and edited in Snapseed

Context

While interacting with my colleague Mallik, we came to a scenario of deploying multiple web applications under single Azure Web App. Well, it is supported. But we never tried it ourselves. So, this time, we thought of doing Hands-on and here what we learned – step by step.

Project Structure & Solution

This is how our solution looks like. We have a single solution called multipledeploy with two projects or web applications in it. We want to publish it in single Web App.

Azure Web App

We configured our Web App having S1 plan with these two path mappings. Note that, these are 2 separate applications.

Publish Profile

In the Publish Profile we made changes to ‘Site name’ and ‘Destination URL’ properties by appending individual site names like multipledeploy1 and 2. This will make sure to deploy these web sites individually in different folders in IIS.

The Problem

This deployed 2 websites in 2 different folders (treated as Applications) in a single Azure Web App. And both these apps ran for the 1st time. However, we got the error.

This is a typical ASP.NET error which says, we can’t run multiple apps in same host/pool. We need to create separate pools for each apps. However, there is no setting for that. So, what’s the solution?

The Solution

When you deploy or publish the app, web.config file is generated on IIS. You can manually add that to your project as well. In that file, you can mention to run the web application in ‘outofprocess‘. Add this value to hostingModel.

This will run both the applications in their own application pool. Refresh or restart the app to see the effect.

Conclusion

It is possible to run multiple web applications in Azure Web App. You just need to make sure you’re publishing these apps in right folders and setting it up to use out of process hosting model.

Happy coding:)

Namaste,
Mayur Tendulkar