Search code examples
azurepowershellweb-applicationsazure-web-app-service

How to use Azure Powershell to change the stack of an Azure WebApp?


Does anyone know how to change the stack of an Azure WebApp? For instance when one creates a webapp with New-AzWebApp, the default stack is .NET 4.0. How does one switch that to DOTNETCORE without having to revert to using the portal? Also how does one specify the stack at creation without resorting to Resource Templates?


Solution

  • As I know, if you use New-AzWebApp, you could not specify the stack at creation, but you could use the command below to switch that to dotnetcore after creation.

    New-AzWebApp -ResourceGroupName <Resource-Group-Name> -Name <web-app-name> -Location centralus -AppServicePlan <app-service-plan-name>
    $PropertiesObject = @{
            "CURRENT_STACK" =  "dotnetcore"
        }
    New-AzResource -PropertyObject $PropertiesObject -ResourceGroupName <ResourceGroupName> -ResourceType Microsoft.Web/sites/config -ResourceName "<web-app-name>/metadata" -ApiVersion 2018-02-01 -Force
    

    enter image description here

    Check in the portal:

    enter image description here