45

I am trying to delete everything related to a mobile app back-end I previously created, and I was able to delete everything but the app service plan.

It shows that the App service plan has no connected apps and no pricing tier, but I still can't delete it:

App Service plan]

And when I try to click on the plan to see its details, the portal goes into an infinite loading state and nothing else happens:

App service plan details

Can anyone help me solve this problem?

alex
  • 6,818
  • 9
  • 52
  • 103
Albert_S
  • 599
  • 1
  • 4
  • 5

9 Answers9

36

I had a similar issue. The app service plan couldn't be deleted, but I wasn't able to access is properly from the Azure Portal. I managed to remove the plan like this:

  1. Make sure all related apps (web jobs, ...) were removed.
  2. Open PowerShell and log in to your Azure account: Login-AzureRmAccount.
  3. Remove the app service plan: Remove-AzureRmAppServicePlan -Name <name> -ResourceGroupName <resourcegroup>.
Ramon de Klein
  • 5,172
  • 2
  • 41
  • 64
  • When in doubt, fall back to scripts! Thx – granadaCoder Nov 09 '17 at 20:39
  • This is the only solution that worked for deleting a Linux app service plan (which can't be scaled to a free tier as another solution suggests). –  Apr 23 '18 at 03:45
  • Yep, this PowerShell script deleted my ghost Plan immediately without a peep – nicdaniau Jul 06 '18 at 10:20
  • I had an App Service Plan with 2 apps on it. I removed the apps, but couldn't delete the Plan. Scripting the removal fixed it for me as well, however, I also had to add `Set-AzureRmContext -SubscriptionId "xxxx-xxxx-xxxx-xxxx"` before the removal command. – Dieter Oct 26 '18 at 06:51
  • I am getting "The term 'Remove-AzureRmAppServicePlan' is not recognized as the name of a cmdlet" error – Sathiamoorthy Sep 15 '21 at 07:42
16

If you delete the ResourceGroup it is located in, it will dissapear.

Nowadays it's possible to move most resources between ResourceGroups. So you can create a new ResourceGroup, for example "ToBeDeleted", and then move the AppServicePlan to "ToBeDeleted" and then remove the ResourceGroup.

enter image description here

Jorn.Beyers
  • 1,784
  • 2
  • 21
  • 26
  • 1
    Gives me a validation error with message "'Microsoft.Web/serverFarms/ServicePlan*****' were not found. The tracking Id is 'b6dfbedf-8a52-4524-9624-b5200e9cff71'. (Code: ResourceNotFound) – Atiq Rahman Jun 15 '17 at 19:42
6

Once I had a WebApp in an App Service Plan (only one). There was some problem with the Aplication, and it was consuming all the CPU of the plan. I then moved the WebApp to another plan. It started to consume all the CPU (~100%) in the new (destination) App Service Plan.

After moving the app, in Azure portal, the original App Service Plan appeared as having "0 apps, 0 slots" (empty), yet the CPU was still around 100%. Weird!

Azure wouldn't let me remove that empty origin App Service Plan, telling me to first remove all the App it contained (which should be none).

I guessed Azure had registered the movement of the WebApp to the destination App Service Plan, yet some process was somehow stuck in the original App Service Plan, and until the process wouldn't end, I wouldn't be able to remove the App Service Plan (hence I would pay for it).

My trick here was to Scale Down that original App Service Plan. It was Premium, and I scaled it down to Free. When you scale up/down, Azure migrate deploys your app on a new set of machines. That is the stuck process would then forcely disappear. No new process was spawned on the new machine, as Azure had no account of any app being deployed on that App Service Plan anyway :)

Once scaled down to Free, I was instantly able to remove the empty plan.

So, in case you have any such problem, scale Up or Down the plan. It will assign new VMs, with no remaining processes nor new app process (as no apps are registred to the empty plan!)

Alexandre Dumont
  • 123
  • 2
  • 10
4

Make sure no Resource Group is attached to the Service Plan.

Nathan Noble
  • 806
  • 7
  • 14
2

I had the same issue and below fix worked for me.

  1. Go to Resource Group tab in Azure portal.
  2. Delete the attached Resource Group and then App Service Plan will delete automatically.
  3. To confirm, go to All Resource tab and you should not see that App Service Plan anymore. Refresh if required or wait if delete is still in-progress.

Hope that helps.

Prakash Tripathi
  • 469
  • 6
  • 12
1

I have just delete a service plan right now without issues.

Looks like any transient situation in azure Web Apps, try again/verify in a few minutes.

If the problem persist you can create a support ticket here:

Support Ticket

enter image description here

Community
  • 1
  • 1
JuanK
  • 2,056
  • 19
  • 32
  • 7
    I rechecked after 2 days and it was automatically deleted. Thanks and sorry for the late reply. For future reference app service plan can not be deleted manually it should delete itself automatically when you delete everything in it. (After some delay) – Albert_S Dec 29 '15 at 22:34
  • As of 2018, app service plans can, and apparently have to, be deleted manually. I had a service plan running empty for almost 3 days without any assigned resources. – Daniel Saner Mar 12 '18 at 11:22
1

After deleting the Recourcegroup, it's no longer possible to rech the Service Plan over the portal!

If you don't have some Important things running on them, you can cancel the subscription. Home --> Subscription --> Cancel subscription.

That stops everything and all billing costs.

Then you can add a new one. To make the new subscription visible, you have to go setting --> Directories + subscriptions --> Default subscription filter --> select new subscription --> logout --> login.

Alex Z
  • 11
  • 2
0

On new Azure portal:

  1. Click on your App service plan
  2. Delete it enter image description here
Sadjad Khazaie
  • 2,102
  • 22
  • 22
0

I had the same problem, also tried the script which executed without errors. In the end I pressed F12 to bring up the browser dev-tools, checked "disable cache" in the network tab and refreshed the web page with the service plans. And it's gone :)

Johan Danforth
  • 4,469
  • 6
  • 37
  • 36