Add Virtual Directory to an Azure Website using Powershell
Looks like a valid (if somewhat complex) answer here:
The short of it is: You gotta use AzureResourceManager and work with a Microsoft.web/sites/config object to get and set Virtual Directories.
I've just been struggling to do this recently, and found a simpler solution here:
$website = Get-AzureRmWebApp -Name "myWebApp" -ResourceGroupName "myResourceGroup" $VDApp = New-Object Microsoft.Azure.Management.WebSites.Models.VirtualApplication $VDApp.VirtualPath = "/TEST" $VDApp.PhysicalPath = "site\\TEST" $VDApp.PreloadEnabled ="YES" $website.siteconfig.VirtualApplications.Add($VDApp) $website | Set-azureRmWebApp
Based on Ben's answer:
$props = @{ "virtualApplications" = @( @{ "virtualPath" = "/"; "physicalPath" = "site\wwwroot"; }, @{ "virtualPath" = "/SOME_VIRTUAL_PATH"; "physicalPath" = "site\wwwroot"; } )}Set-AzureRmResource ` -ResourceGroupName $resourceGroupName ` -ResourceType "Microsoft.Web/sites/config" ` -ResourceName "$appServiceName/web" ` -PropertyObject $props ` -ApiVersion "2015-08-01" ` -Force