Eniola
Eniola

Reputation: 720

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?

Upvotes: 1

Views: 943

Answers (2)

Andrew Brach
Andrew Brach

Reputation: 11

Read its current configuration with this

PS> $entityInfo = get-AzWebApp -ResourceGroupName "ResourceGroupName" -Name "Name" 

Then go through its properties

PS > $entityInfo.SiteConfig.NetFrameworkVersion

Returns v2.0

PS > $entityInfo.SiteConfig.Use32BitWorkerProcess

Returns True

Update the local copy of the individual settings like this

PS> $entityInfo.SiteConfig.NetFrameworkVersion = "v6.0"
PS> $entityInfo.SiteConfig.Use32BitWorkerProcess = $false

And save it back to the App Service configuration like this

PS> $entityInfo | Set-AzWebAppSlot

Upvotes: 1

Joy Wang
Joy Wang

Reputation: 42063

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

Upvotes: 2

Related Questions