In this quick post, we will read about the steps we need to take if we accidentally delete it. By executing a few PowerShell commands, it can be easily fixed.
Prerequisites
- An active Azure subscription
- Azure Az PowerShell module (Only for PowerShell)
- Azure Cloud Shell
The Lab
Let us see how you can restore an accidentally Azure Web App to a resource group.
The screenshot below is from a test azure web app before I “accidentally” delete it.
The Azure Web App has been deleted and the resource group includes App Insights and the App Service Plan.
Now, let us check the deleted azure web app details.
We can view the details by running the Get-AzDeletedWebApp command, like the one below:
Step 1. Execute the below PowerShell command to get the deleted web app details.
Get-AzDeletedWebApp -Name "Deleted Web App name" -Location "Web App region"
We can no longer use the Azure Web App because it has been deleted.
The next and most important step is to run the Restore-AzDeletedWebApp command in order to restore the We App to the resource group.
Restore-AzDeletedWebApp -ResourceGroupName "RG Name" -Name "Deleted WebApp Name" -TargetAppServicePlanName "Azure App Service Plan Name"
A few seconds later the deleted Azure Web App is online and we can access it.
Related articles
- Restore deleted App Service app Using PowerShell
- Restore(Undelete) Deleted Web Apps
- Azure Az PowerShell module