Skip to content

Instantly share code, notes, and snippets.

@mmckechney
Last active October 17, 2023 23:16
Show Gist options
  • Save mmckechney/dcd89bee666217f8a7529ebc84716ec1 to your computer and use it in GitHub Desktop.
Save mmckechney/dcd89bee666217f8a7529ebc84716ec1 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 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

@docouto
Copy link

docouto commented May 17, 2023

Thanks for sharing! I've been struggling to get the tier information right from a dozen of web apps.

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