Restore deleted App Service app Using PowerShell
If you happened to accidentally delete your app in Azure App Service, you can restore it using the commands from the Az PowerShell module.
Re-register App Service resource provider
Some customers might encounter an issue where retrieving the list of deleted apps fails. To resolve the issue, run the following command:
Register-AzResourceProvider -ProviderNamespace "Microsoft.Web"
List deleted apps
To get the collection of deleted apps, you can use
For details on a specific deleted app you can use:
Get-AzDeletedWebApp -Name <your_deleted_app> -Location <your_deleted_app_location>
The detailed information includes:
- DeletedSiteId: Unique identifier for the app, used for scenarios where multiple apps with the same name have been deleted
- SubscriptionID: Subscription containing the deleted resource
- Location: Location of the original app
- ResourceGroupName: Name of the original resource group
- Name: Name of the original app.
- Slot: the name of the slot.
- Deletion Time: When was the app deleted
Restore deleted app
Once the app you want to restore has been identified, you can restore it using
Restore-AzDeletedWebApp -ResourceGroupName <my_rg> -Name <my_app> -TargetAppServicePlanName <my_asp>
The inputs for command are:
- Resource Group: Target resource group where the app will be restored
- Name: Name for the app, should be globally unique.
- TargetAppServicePlanName: App Service plan linked to the app
Restore-AzDeletedWebApp will restore both your app configuration as well a content. If you want to only restore content, you use the
-RestoreContentOnly flag with this commandlet.
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.
You can find the full commandlet reference here: Restore-AzDeletedWebApp.