Skip to content

Instantly share code, notes, and snippets.

@docouto
Forked from mmckechney/Manage-App-Service-Plan.md
Last active May 17, 2023 21:23
Show Gist options
  • Save docouto/aa6e9fadd1fb550ba514eb4c7b61f70c to your computer and use it in GitHub Desktop.
Save docouto/aa6e9fadd1fb550ba514eb4c7b61f70c to your computer and use it in GitHub Desktop.
PowerShell and CLI to manage App Service Plan sizing

Manage App Service Plan count and SKU

Get the Service Plan, SKU, hosts and webapps running on it.

Get-AzAppServicePlan| select name, status,georegion,kind, NumberOfSites, @{n="Size"; e={($_.sku).size}}, @{n="Nodes"; e={($_.sku).capacity}}, @{n="sku name"; e={($_.sku).tier}}, @{n="Apps"; e={$((Get-AzWebApp -AppServicePlan $_).name)}}

Get the number of worker nodes serving the app service plan

(Get-AzAppServicePlan -ResourceGroupName "<resource group name>" -Name "<app service plan name>").Sku.Capacity
az appservice plan show --resource-group "<resource group name>" --name "<app service plan name>" --output jsonc --query "sku.capacity"

Update the number of worker nodes

Since you are leveraging PremiumV2, the allowed values are 1-30

Set-AzAppServicePlan -ResourceGroupName "<resource group name>" -Name "<app service plan name>" -NumberOfWorkers <1 - 30>
az appservice plan update --resource-group "<resource group name>" --name "<app service plan name>" --number-of-workers <1 - 30>

Gets the SKU (pricing tier) for the app service plan

(Get-AzAppServicePlan -ResourceGroupName "<resource group name>" -Name "<app service plan name>").Sku.Size
az appservice plan show --resource-group "<resource group name>" --name "<app service plan name>" --output jsonc --query "sku.size"

Updates the SKU (pricing tier) for the app service plan

Set-AzAppServicePlan -ResourceGroupName "<resource group name>" -Name "<app service plan name>" -WorkerSize "<Small | Medium | Large>"
az appservice plan update --resource-group "<resource group name>" --name "<app service plan name>" --sku "<P1v2 | P2v2 | P3v2>"

Getting the available Skus, sizes and worker count for a plan

Unfortunately, there isn't a PowerShell to get the available SKUs. Instead, you can get this via a REST call. The documentation for this can be found here:

https://docs.microsoft.com/en-us/rest/api/appservice/appserviceplans/getserverfarmskus#code-try-0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment