Remove Auto Scaling from an Azure App Service using Azure PowerShell
I needed to remove some auto scale settings from one of my App Services using Azure PowerShell so I decided to document that here. Here are the steps:
- Set the subscription context
- Get the existing Auto Scale rules based on Resource Group
- Remove the Auto Scale rule
Please keep reading for more details.
Execute the following cmdlet to login.
Executing that cmdlet opens a challenge/response window, enter your credentials and the result is similar to that shown in Figure 1.
Figure 1, how to login into Azure using Azure PowerShell
Set the subscription context
Next, execute the Set-AzureRmContext cmdlet.
Set-AzureRmContext -SubscriptionId "25ec5bae-####-####-####-############"
Set the subscription Id to the subscription into which you want to create the Azure App Service Web App, the results is similar to that in Figure 2.
Figure 2, how to set the Azure subscription using Azure PowerShell
Get the existing Auto Scale rules based on Resource Group
You set Auto Scale rules on App Service Plans which I discuss here. Keep in mind if you create an Auto Scale rule, when it is triggered all the App Services running on that ASP will scale out. As well, when you deleted the Auto Scale rule, it is for all the App Services running in that ASP. Execute this cmdlet to find the name of the Auto Scale rule you would like to remove.
Get-AzureRmAutoscaleSetting -ResourceGroup "Default-Web-NorthCentralUS"
I will assume you can already find the Resource Group in which the ASP is running. You will see that on the Overview blade of the App Service Plan. The output of the cmdlet is shown in Figure 3.
Figure 3, how to view Auto Scale rule using Azure PowerShell
Remove the Auto Scale rule
Lastly, use the name of the Auto Scale rule with the following cmdlet to delete it.
Remove-AzureRmAutoscaleSetting -ResourceGroup "Default-Web-NorthCentralUS" -Name "CH1S1-Default-Web-NorthCentralUS"
The output is represented in Figure 4.
Figure 4, how to remove Auto Scale rules using Azure PowerShell
Then execute the Get-AzureRmAutoscaleSetting cmdlet and the rule will not be present any longer.