How to delete an Azure App Service Plan using Azure PowerShell
#Azure #AzurePowerShell #AppService #PowerShell
I wrote an article here about what an App Service Plan is. In simple terms it is the Virtual Machine that is running your web sites. It has a different name becuase the ASP can be SMALL, MEDIUM or LARGE in size or have certain features based on the modes FREE, SHARED, BASIC, STANDARD or PREMIUM.
I also wrote some other articles about using Azure PowerShell listed below:
- Moving an Azure App Service
- Deploy an App Service using Azure PowerShell to a Deployment Slot
- How to tell which Azure PowerShell version you are running
- And some others here
To delete an ASP, perform the following:
- Login via PowerShell
- Remove the App Service Plan
Once you complete the above, you will have deleted an ASP using Azure PowerShell #Azure #AzurePowerShell
Login via PowerShell
I like to use the Windows PowerShell ISE console app because I find it more friendly, but choose you own approach. Enter the following command to login your PowerShell to Azure:
This will open a challenge/response window where you can enter your userid and password, use the same credentials that you used when you created the PowerShellResourceGroup in the previous section. Once successfully logged in, you will see some output similarly to that shown in Figure 1.
Figure 1, Login to the Azure Portal using PowerShell
Confirm that the SubscriptionId shown in the output is the same SubscriptionId into which you created the PowerShellResourceGroup. It is common to have multiple subscriptions linked to the same user credentials, so if you see a different SubscriptionId, try executing the Set-AzureSubscription or Set-AzureRmContext cmdlet which can set your session to the correct subscription.
Remove the App Service Plan
In most cases, when you have removed all the App Services from the App Service Plan it gets automatically removed. This is done becuase there is no need to get billed for a VM if there is nothing runnng on it. However, if you ever find that you have an ASP running with nothing running on it and you cannot remove it from the portal, try this.
Remove-AzureRmAppServicePlan -Name "ASPNAME" -ResourceGroupName "RG" -Force
There is no output when I ran the command, as shown in Figure 2, however it was removed and confirmed on the portal. It might take some time, but ultimately it gets removed.
Figure 3, remove an App Service Plan from Azure
Also, check out this article: Using Azure Resource Manager-Based PowerShell to Manage Azure Web Apps