If you have deleted Azure Web App accidentally and looking to recover it, then there is a way to do that. It has been there for quite a long time, so I thought writing a blog on it. This feature is not available on Azure Portal today.
Undelete is available for all App Service plans. Only sites deleted in the past 30 days can be restored.
You can undelete a deleted web app and restore the following:
- The content of the deleted app.
- The configuration of the app. (The commands allow you to skip the restoration of the app configuration.)
- The *.azurewebsites.net hostname, if it is still available.
Currently, the undelete commands support the restoration of apps deleted from multiple tenants that use Windows and Linux. You can restore it yourself by using the commands from the Az PowerShell module. I will use Azure Cloud Shell for the demo.
To get started, install the Az PowerShell module or use Azure Cloud Shell. You can then do the following:
First, get the list of deleted Azure Web Apps. Use the optional parameters to filter the apps that have a specific name or that belong to a specific resource group or App Service plan.
Get-AzDeletedWebApp -name <name of the deleted app>
In this demo, assuming azwebapprecoverdemo Azure Web App have been deleted. To get the list, we need to run the below command.
Get-AzDeletedWebApp -Name azwebapprecoverdemo
This command will return the information about the deleted app such as when it was deleted and what is its DeletedSiteId.
Recover the Azure Web App:
Use the below command to recover the Web App.
Restore-AzDeletedWebApp -ResourceGroupName <deleted app rg> -Name <deleted app name> -TargetAppServicePlanName <App Service plan name to create an app to restore to>
For our Web App the command would be:
Restore-AzDeletedWebApp -ResourceGroupName AzWebAppDemo -Name azwebapprecoverdemo -TargetAppServicePlanName ASP-AzWebAppDemo
I hope you find this useful.