If you happened to accidentally delete your web app in Azure App Service then up until recently you had to open a support case in order to get it restored. But now you can restore it yourself by using the commands from the Az PowerShell module. This blog post explains how to do that.
Assume you used to have a site named “undeletesiteexample” and you have deleted it accidentally. The first step to recover it is to get the details of the deleted app:
Get-AzDeletedWebApp -Name undeletesiteexample
This command will return the information about the deleted app such as when it was deleted and what is its DeletedSiteId. The DeletedSiteId is used to uniquely identify the deleted app in case there have been several apps with the same name deleted.
The next step is to restore the deleted app by using
Restore-AzDeletedWebApp -ResourceGroupName SwapTestRG -Name undeletesiteexample -TargetAppServicePlanName SwapTestASP
Or alternatively you can pipe the output of the
$deletedSiteInfo = Get-AzDeletedWebApp -Name undeletesiteexample $deletedSiteInfo | Restore-AzDeletedWebApp -ResourceGroupName SwapTestRG -Name undeletesiteexample -TargetAppServicePlanName SwapTestASP
Restore-AzDeletedWebApp can be used to restore a site using the same or different name. Also you can chose where to restore it to, e.g. which resource group, app service plan or deployment slot. In addition you can also chose to restore just the content (
[-RestoreContentOnly]) or the content and the site’s configuration settings.
Note that if the app was hosted on and then deleted from an App Service Environment then it can be restored only if the corresponding App Service Environment still exist.
11 thoughts on “How to restore a deleted Azure Web App”
What if you delete the web app and want to recreate it with the same name.
I’m noticing that Microsoft is keeping track of the used name for a long time now?
Can you somehow clear the used name so you can reuse it again?
It should be possible to recreate a web app with the same name. What error do you get when you attempt to do it?
Is it application for function app also?
I observer we are not able to restore the function app
Arjun, currently it is not possible to restore a deleted function app.
Is it possible to recover the entire resource group and the databricks notebook if it is deleted accidentally?
Thanks for this really useful post. I’ve created an App Service Plan with a Basic SKU under dev/test however, no matter what I do I always get an error that read: “Restore-AzDeletedWebApp : Web app recovery requires Basic SKU.”
Strangely enough the app is created but no content/config/etc are restored – Do you have any insights into this error?
Burhaan, thanks for reporting this. The error is a bit misleading. What that means is that the app was in a Free or Shared SKU at the time it had been deleted. That’s why it cannot be restored now. The fact that the empty app still gets created after reporting this error sounds like a bug. I’ll report this to the product team to investigate and fix.
The official documentation for how to restore site is available here: https://docs.microsoft.com/en-us/azure/app-service/app-service-undelete
Hello, I have deleted the published static content folder from the app service accidentally. there is no backup or snapshot recovery setting configured. Can I recover my static back by any means
Thanks in advance
I keep getting the error message Restore-AzDeletedWebApp: Web app recovery requires Basic SKU. When i try to restore the accidentally deleted app.
Any workarounds – pls suggest. Its a little urgent
hello @Satesh it basically is saying the require basic plan must be of a standard type atleast..