How to restore a deleted Azure Web App

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
Get-AzDeletedWebApp output

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 command:

Restore-AzDeletedWebApp -ResourceGroupName SwapTestRG -Name undeletesiteexample -TargetAppServicePlanName SwapTestASP
Restore-AzDeletedWebApp output

Or alternatively you can pipe the output of the Get-AzDeletedWebApp command:

$deletedSiteInfo = Get-AzDeletedWebApp -Name undeletesiteexample
$deletedSiteInfo | Restore-AzDeletedWebApp -ResourceGroupName SwapTestRG -Name undeletesiteexample -TargetAppServicePlanName SwapTestASP

The 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”

  1. 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?

  2. Is it possible to recover the entire resource group and the databricks notebook if it is deleted accidentally?

  3. 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?

    1. 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.

    1. 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

  4. Hi,

    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


Leave a Reply

Your email address will not be published. Required fields are marked *