# Variables
$ResourceGroupName = "efgh001"
$WebAppName = "abcd001"
$WebAppServicePlanName = "wxyz001"
$tier = "PremiumV2"
$workerSize = "Large"
# Display current webapp service plan size
$myAppServicePlan = Get-AzAppServicePlan -Name $WebAppServicePlanName -ResourceGroupName $ResourceGroupName
Write-Host "Current AppServicePlan Size is" $myAppServicePlan.Sku.Size
#Stoping webjobs by setting WEBJOBS_STOPPED to 1
$myWebApp = Get-AzWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName
$appsettingsCurrent = $myWebApp.SiteConfig.AppSettings
$appSettingsNew = @{}
foreach ($kvp in $appsettingsCurrent) {
$appSettingsNew[$kvp.Name] = $kvp.Value
}
$appSettingsNew["WEBJOBS_STOPPED"] = "1"
Set-AzWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName -AppSettings $appSettingsNew
#Upgrade AppServicePlan size
Set-AzAppServicePlan -Name $WebAppServicePlanName -ResourceGroupName $ResourceGroupName -Tier $tier -WorkerSize $workerSize
# Display updated webapp service plan size
$myAppServicePlan = Get-AzAppServicePlan -Name $WebAppServicePlanName -ResourceGroupName $ResourceGroupName
Write-Host "Updated AppServicePlan Size is" $myAppServicePlan.Sku.Size
#Starting webjobs by setting WEBJOBS_STOPPED to 0
$myWebApp = Get-AzWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName
$appsettingsCurrent = $myWebApp.SiteConfig.AppSettings
$appSettingsNew = @{}
foreach ($kvp in $appsettingsCurrent) {
$appSettingsNew[$kvp.Name] = $kvp.Value
}
$appSettingsNew["WEBJOBS_STOPPED"] = "0"
Set-AzWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName -AppSettings $appSettingsNew