How to restore deleted Azure Web App + Contents
We accidentally deleted an azure web app and needed to find a way to recover it plus the contents and configuration. In other words, we needed the web app back exactly as it was before deletion.
The only available option for web app recovery as of this writing is through Azure CLI and not yet on GUI(Azure portal).
N.B You can only recover web apps deleted in the last 30 days
Step One: — Open Azure CLI to run az webapp deleted commands
az webapp deleted list [ — name]
[ — resource-group]
[ — slot]
[ — subscription]
Run the az webapp deleted list — output table to list out all deleted web apps in your default subscription and for all resource groups.
Run az webapp deleted list — name deletedappservicename to find a specific app service. Note the id as it would be used to uniquely identify the app and restore it. The id also comes in handy if you have deleted apps in the same subscription/resource group with the same name
Step Two: — Create a web app to restore the app service to.
Sign in to azure portal, create a web app with same name as the deleted app service. For example, the deleted app had a URL of deleted.azurewebsites.net, so create a webapp with a name that matches same if it’s still available.
Note that a Web app cannot be restored to an API app and it’s important to create an app closely matches what you are trying to restore.
Step Three:
Open azure CLI and Run az webapp deleted restore command
az webapp deleted restore — deleted-id
[ — ids]
[ — name]
[ — resource-group]
[ — restore-content-only]
[ — slot]
[ — subscription]
you can specify the slot to restore with the [ — slot] flag and also to restore the web app contents only without the configurations with the [ — restore-content-only] flag.
Ensure to save the deleted app id copied from Step one
Run the command below to restore the app service to the web app created in Step 2 above plus contents and configuration.
az webapp deleted restore — deleted-id — resource-group — name
I got a number of errors while restoring one of which was because Web app recovery requires Basic SKU and the app was on the Free SKU. Be sure to check the activity logs of the app, if you encounter errors while restoring.
I hope this article helps :)
Thank you!