Using MSDeploy to deploy to nested virtual applications in Azure Web Apps

Azure provides many ways to scale and structure web site and virtual applications. I recently needed to deploy the following structure where each service endpoint was its own Visual Studio Web Application Project built as a MSDeploy Package

To do this in the Azure Portal in …

  1. Created a Web App for the site http://demo.azurewebsites.net This pointed to the disk location sitewwwoot, I disabled the folder as an application as there is not application running at this level 
  2. Created a virtual directory api point to sitewwrootapi, again disabling this folder as an application 
  3. Created a virtual application for each of my services, each with their own folder

image

I knew from past experience I could use MSDeploy to deploy to the root site or the api virtual directory. However I found when I tried to deploy to any of the service virtual applications I got an error that the web site could not be created. Now I would not expect MSDEPLOY to create a directory so I knew something was wrong at the Azure end.

The fix in the end was simple, it seems the folder service folders e.g sitewwwrootapiservice1 had not been created by the Azure Portal when I created the virtual directory. I FTP’d onto the web application and create the folder sitewwwrootapiservice1  once this was done MSDEPlOY worked perfectly, and I could build the structure I wanted.