How to Create Virtual Directories in Azure Web Apps with PowerShell

Until Microsoft adds a native command that easily connects virtual directories to Azure Web apps, we’re going to have to do it ourselves.

n the era before cloud computing, writing an entire article just to create an IIS virtual directory in PowerShell would not have been necessary. After all, just run the New-WebVirtualDirectory PowerShell command and be done with it! Nowadays, with the cloud reinventing just about every aspect of IT, things are done a little differently. Perhaps one day we’ll have a native New-AzureWebVirtualDirectory command inside of the Azure PowerShell module. But until then, we’ll just have to build our own. Here’s how.

Creating and attaching a virtual directory to an Azure Web app consists of three steps:

  1. Retrieving the Microsoft.Azure.Management.WebSites.Models.Site object.
  2. Creating a Microsoft.Azure.Management.WebSites.Models.VirtualApplication object.
  3. Assigning the VirtualApplication object to the Site object.

Read more at MCPMag

Leave a Reply