We can restore a delete web app,
Steps to restore a deleted Web App
We can restore deleted webapp using powershell (Restore deleted apps - Azure App Service | Microsoft Docs) or Azure CLI (az webapp deleted | Microsoft Docs). In the steps below, I have used PowerShell cmdlets in Cloud shell:
PS /home/amol> Get-AzDeletedWebApp
PS /home/amol> Get-AzDeletedWebApp -ResourceGroupName "LabDemo" -Name "labsampledemo"
PS /home/amol> $deletedSites = Get-AzDeletedWebApp -ResourceGroupName "LabDemo" -Name "labsampledemo"
PS /home/amol> write-output $deletedSites[0]
PS /home/amol> Restore-AzDeletedWebApp -TargetResourceGroupName "LabDemo" -TargetName "labsampledemo" - TargetAppServicePlan "LabSampleDemo" -InputObject $deletedSites[0]
Note: For debugging PowerShell or Azure CLI errors, -Debug could be used for a detailed error message.
Important: It is advisable to always check the type of deleted app that you are trying to restore. Make sure that the new app that you have created where you would like to restore the deleted app is of the same type. Else you will get an error.
The below given Azure CLI command, could be used to validate the type\kind of deleted app. Look the value of kindPropertiesKind attribute in the result.
|
Multiple delete versions available
We could come across scenarios where we have multiple versions of the deleted app. This could happen when the same app was deleted and restored multiple times with same name.
When we run Get-AzDeletedWebApp, we can differentiate among various versions by looking at DeletionTime property.
PS /home/amol> Get-AzDeletedWebApp -ResourceGroupName "LabDemo" -Name "labsampledemo"
If we simply use restore -name -resource group in Get-AzDeletedWebApp cmdlet, then it would restore the most recently deleted site version.
If we want to pick one of the older versions, loading the webapp details into a variable helps.
This way we can pick any one the items from the array.
PS /home/amol> $deletedSites = Get-AzDeletedWebApp -ResourceGroupName "LabDemo" -Name "labsampledemo"
PS /home/amol> Restore-AzDeletedWebApp -TargetResourceGroupName "LabDemo" -TargetName "labsampledemo" -TargetAppServicePlan "LabSampleDemo" -InputObject $deletedSites[0]
Curious case of Undeleting Function Apps
If we are not sure if the deleted app was FunctionApp, we can verify that using this Azure CLI command, and check the value of kindPropertiesKind attribute in the result. For webapp, value of this attribute will be "app" and for Function App it would be "functionapp".
az webapp deleted list --name <name of deleted site> |
If the Function App was hosted on Dedicated hosting plan, then we have a way to restore it.
Restore-AzDeletedWebApp -ResourceGroupName <RGofnewapp> -Name <newApp> -deletedId "/subscriptions/xxxx/providers/Microsoft.Web/locations/xxxx/deletedSites/xxxx"
Currently there is no support for Undelete (Restore-AzDeletedWebApp) Function Apps that are hosted on Consumption plan or Elastic premium plan. These are the scenarios where content resides on Azure Files. If you have not 'hard' deleted the azure files storage account or if it exists and has not been deleted, then you may the steps below as workaround:
{
"name": "AzureWebJobsStorage",
"value": "<Connection String for storage account of deleted site>",
"slotSetting": false
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "<Connection String for storage account of deleted site>",
"slotSetting": false
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "<storage account file share> ",
"slotSetting": false
}
Alternatively, if you have the function app content,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.