Update Azure Website instance size (Small, Medium, Large) with Powershell

后端 未结 1 1766
难免孤独
难免孤独 2021-01-06 12:24

Is there a way to scale an Azure WebSite instance size (not instance count) using PowerShell? I haven\'t found the way.

I know it can be done using

相关标签:
1条回答
  • 2021-01-06 13:23

    Yes, you first need to know the name of the Resource Group and Web Hosting Plan to which your website belongs, which you can get from the new Azure Portal. Then you can change the worker size to 0 (Small), 1 (Medium) or 2 (Large).

    Switch-AzureMode AzureResourceManager
    
    $resourceGroup = "MyResourceGroup"
    $webHostingPlan = "MyWebHostingPlan"
    
    $whp = Get-AzureResource `
        -Name $webHostingPlan `
        -ResourceGroupName $resourceGroup `
        -ResourceType "Microsoft.Web/serverFarms" `
        -ApiVersion 2014-04-01
    
    $newWorkerSize = 1
    $whp.Properties.workerSize = $newWorkerSize
    $whp.Properties.workerSizeId = $newWorkerSize
    
    Set-AzureResource `
        -Name $webHostingPlan `
        -ResourceGroupName $resourceGroup `
        -ResourceType "Microsoft.Web/serverFarms" `
        -ApiVersion 2014-04-01 `
        -PropertyObject $whp.Properties
    
    0 讨论(0)
提交回复
热议问题