azurepowershellazure-devopsazure-web-app-service

Adding / setting Virtual Applications (Path mappings) to a Web App (App Service Azure) - via Powershell Script


Is it possible to add, via Powershell Script, Virtual Application Paths, Virtual and Physical to a Web App (App Service - Azure), or this is just possible, via graphical interface, in the Azure portal ?

Thank you.


Solution

  • Yes, this possible with Azure Powershell

    Microsoft's documentation has an example for this

    $webapp=Get-AzWebApp -ResourceGroupName <group-name> -Name <app-name>
    
    # Set default / path to public subdirectory
    $webapp.SiteConfig.VirtualApplications[0].PhysicalPath= "site\wwwroot\public"
    
    # Add a virtual application
    $virtualApp = New-Object Microsoft.Azure.Management.WebSites.Models.VirtualApplication
    $virtualApp.VirtualPath = "/app2"
    $virtualApp.PhysicalPath = "site\wwwroot\app2"
    $virtualApp.PreloadEnabled = $false
    $webapp.SiteConfig.VirtualApplications.Add($virtualApp)
    
    # Save settings
    Set-AzWebApp $webapp