|
1 | 1 | --- |
2 | 2 | title: Restore Deleted Apps |
3 | | -description: Learn how to restore a deleted app in Azure App Service. Avoid the headache of an accidentally deleted app. |
| 3 | +description: Restore a deleted app in Azure App Service to another similar app created in the same region. |
4 | 4 | author: seligj95 |
5 | 5 | ms.author: jordanselig |
6 | | -ms.date: 10/4/2023 |
| 6 | +ms.date: 03/23/2026 |
7 | 7 | ms.topic: how-to |
8 | 8 | ms.service: azure-app-service |
9 | 9 | ms.custom: |
10 | 10 | - devx-track-azurepowershell |
11 | 11 | - sfi-ropc-nochange |
| 12 | +#customer intent: As an App Service developer, I want to restore a deleted app in Azure App Service, so I can continue to use the app content and configuration settings. |
12 | 13 | --- |
13 | 14 |
|
14 | | -# Restore a deleted App Service app |
| 15 | +# Restore a deleted app in App Service |
15 | 16 |
|
16 | | -If you accidentally deleted an app in Azure App Service, you can now restore it by using the Azure portal or PowerShell. |
| 17 | +If you deleted an app in Azure App Service, you can restore the app and continue to use the existing contents and settings. The process overwrites another _target_ app with the contents and settings of the deleted web app. |
17 | 18 |
|
18 | | -- This feature isn't supported for apps hosted on App Service plans using the Free and Shared tiers. |
19 | | -- Deleted apps are purged from the system 30 days after the initial deletion. After an app is purged, it can't be recovered. |
20 | | -- Undelete functionality isn't supported for function apps hosted on the Consumption plan or Elastic Premium plan. |
21 | | -- If the app was hosted on and then deleted from an App Service Environment, it can be restored only if the corresponding App Service Environment still exists. |
| 19 | +There are several conditions for restoring a deleted app: |
22 | 20 |
|
23 | | -## Restore a deleted App Service app by using the Azure portal |
| 21 | +- The deleted app must be created in a paid Azure App Service plan. Apps created in the Free and Shared tiers aren't supported. |
| 22 | +- The deleted app must be present in the system. Deleted apps are purged from the system 30 days after the initial deletion. After an app is purged, it can't be restored. |
| 23 | +- If the app is hosted on and then deleted from an App Service Environment, it can be restored only if the corresponding App Service Environment still exists. |
| 24 | +- You can't restore a function app hosted on the Consumption plan or Elastic Premium plan. |
24 | 25 |
|
25 | | -If you deleted your app in Azure App Service, you can restore it from the portal by following these steps: |
| 26 | +This article describes how to restore a deleted web app by following procedures for the Azure portal or Azure PowerShell. You can also [restore a deleted Azure Functions app](#restore-a-deleted-azure-functions-app). |
26 | 27 |
|
27 | | -1. Go to **App Services** in the Azure portal. |
28 | | -1. Select **Manage Deleted Apps**. |
29 | | -1. Select **Subscription**. |
30 | | -1. From the dropdown list, select the deleted app. Apps that were deleted in the last 30 days appear in the list. |
31 | | -1. Select the destination app from the dropdown list that correlates to where you want to restore your app. |
32 | | -1. If you want to restore the deleted app to a slot of the destination app, select the slot checkbox and select available slots from the dropdown list. |
33 | | -1. By default, only app content is restored. If you want app configuration to also be restored, select **Restore App configuration**. |
| 28 | +## Prerequisites |
34 | 29 |
|
35 | | -## Restore a deleted App Service app by using PowerShell |
| 30 | +- To complete the restore in the **Azure portal**, you need an existing target app that is the same type as the deleted app, and created in the same region. |
36 | 31 |
|
37 | | -If you deleted your app in Azure App Service, you can restore it by using the commands from the [`Az PowerShell module`](/powershell/azure/). |
| 32 | +## Restore a deleted web app |
38 | 33 |
|
39 | | -## Re-register App Service resource provider |
| 34 | +You can restore a deleted web app in Azure App Service in the Azure portal or by using the [`Az PowerShell module`](/powershell/azure/). |
40 | 35 |
|
41 | | -Some customers might experience failure to retrieve the list of deleted apps. To resolve the issue, run the following command: |
| 36 | +- If you use PowerShell, you can restore to an existing app or create a new app. |
42 | 37 |
|
43 | | -```powershell |
44 | | - Register-AzResourceProvider -ProviderNamespace "Microsoft.Web" |
45 | | -``` |
| 38 | +- In the Azure portal, you can restore only to an existing web app. |
46 | 39 |
|
47 | | -## List deleted apps |
| 40 | +- Both options allow you to restore the deleted content only, or both the content and the configuration settings. |
48 | 41 |
|
49 | | -To access the collection of deleted apps, you can use `Get-AzDeletedWebApp`. |
| 42 | +- The restore process doesn't include any custom domains, bindings, or certificates that might be imported to the deleted app. After you restore the deleted app, you need to reimport these settings. |
50 | 43 |
|
51 | | -To get details on a specific deleted app, you can use: |
| 44 | +# [Azure portal](#tab/portal) |
52 | 45 |
|
53 | | -```powershell |
54 | | -Get-AzDeletedWebApp -Name <your_deleted_app> -Location <your_deleted_app_location> |
55 | | -``` |
| 46 | +1. In the Azure portal, go to **App Services**. |
| 47 | + |
| 48 | +1. In the top menubar, select **Manage Deleted Apps**. The **Manage Deleted App Services** pane opens. |
| 49 | + |
| 50 | +1. Select the **Subscription** that contains the deleted app. |
| 51 | + |
| 52 | +1. Use the **Deleted App Service** dropdown list and select the deleted app. |
| 53 | + |
| 54 | + > [!NOTE] |
| 55 | + > The list shows only apps deleted in the last 30 days. |
| 56 | +
|
| 57 | + After you select the deleted app, the pane refreshes to show the app region and type. |
| 58 | + |
| 59 | +1. Use the **Replacement App Service** dropdown list and select the existing app to use as the target for the restore process. |
| 60 | + |
| 61 | +1. By default, only app content is restored. If you want to also restore the app configuration, select the **Restore App Configuration** checkbox. |
| 62 | + |
| 63 | +1. Select **Recover**. |
| 64 | + |
| 65 | +# [Azure PowerShell](#tab/azure-powershell) |
| 66 | + |
| 67 | +Run the following commands to restore the deleted web app. |
| 68 | + |
| 69 | +> [!NOTE] |
| 70 | +> The following sections provide information for restoring a web app. To restore a deleted Azure Functions app, see [Restore a deleted Azure Functions app](#restore-a-deleted-azure-functions-app) later in this article. |
| 71 | +
|
| 72 | +### Identify the deleted app to restore |
| 73 | + |
| 74 | +1. Re-register the App Service resource provider, which ensures the system can retrieve the list of deleted apps: |
| 75 | + |
| 76 | + ```powershell |
| 77 | + Register-AzResourceProvider -ProviderNamespace "Microsoft.Web" |
| 78 | + ``` |
| 79 | + |
| 80 | +1. Retrieve the list of deleted apps with the `Get-AzDeletedWebApp` command: |
| 81 | + |
| 82 | + ```powershell |
| 83 | + Get-AzDeletedWebApp |
| 84 | + ``` |
| 85 | + |
| 86 | + The output shows detailed information for each deleted app: |
| 87 | + |
| 88 | + - **Deleted Site ID**: Unique identifier for the app, which is used for scenarios where multiple apps with the same name are deleted. |
| 89 | + - **Subscription ID**: Subscription that contains the deleted resource. |
| 90 | + - **Location**: Location of the original app. |
| 91 | + - **Resource Group Name**: Name of the original resource group. |
| 92 | + - **Name**: Name of the original app. |
| 93 | + - **Slot**: Name of the slot, such as _Production_. |
| 94 | + - **Deletion Time**: Date (mm/dd/yyyy) and time when the app was deleted. |
| 95 | + |
| 96 | +1. Review the list and find the deleted web app you want to restore. |
| 97 | + |
| 98 | + To see the details for a specific deleted app, run the command again with the app name and location. |
| 99 | + |
| 100 | + Replace the `<deleted-app-name>` and `<deleted-app-location>` values with the deleted app information. |
| 101 | + |
| 102 | + ```powershell |
| 103 | + Get-AzDeletedWebApp -Name <deleted-app-name> -Location <deleted-app-location> |
| 104 | + ``` |
| 105 | + |
| 106 | +### Restore the deleted web app |
| 107 | + |
| 108 | +After you identify the deleted app to restore, use the [`Restore-AzDeletedWebApp`](/powershell/module/az.websites/restore-azdeletedwebapp) command. |
| 109 | + |
| 110 | +- The command restores a deleted web app into a target web app. The process overwrites the target app with the contents and settings of the deleted web app. |
56 | 111 |
|
57 | | -The detailed information includes: |
| 112 | +- The command requires various parameters for information about the deleted app or target app: |
58 | 113 |
|
59 | | -* **DeletedSiteId**: Unique identifier for the app, used for scenarios where multiple apps with the same name were deleted. |
60 | | -* **SubscriptionID**: Subscription that contains the deleted resource. |
61 | | -* **Location**: Location of the original app. |
62 | | -* **ResourceGroupName**: Name of the original resource group. |
63 | | -* **Name**: Name of the original app. |
64 | | -* **Slot**: Name of the slot. |
65 | | -* **Deletion Time**: When the app was deleted. |
| 114 | + - `Name`: The name of the deleted app or the target app, as indicated by the command. |
| 115 | + - `ResourceGroupName`: The name of the resource group that contains the deleted app. |
| 116 | + - `Slot`: The slot of the deleted app to restore in the target app. |
| 117 | + - `TargetResourceGroupName`: The name of the resource group that contains the target app. |
| 118 | + - `TargetName`: The name of the target app. If you want the command to create a new app, specify a globally unique name. |
| 119 | + - `TargetAppServicePlanName`: The App Service plan to link with the target app. |
66 | 120 |
|
67 | | -## Restore deleted app |
| 121 | +- When the target parameters aren't specified, the command sets the target values by using the deleted web app's resource group, name, and slot. |
68 | 122 |
|
69 | | ->[!NOTE] |
70 | | -> |
71 | | ->* `Restore-AzDeletedWebApp` isn't supported for function apps hosted on the Consumption plan or Elastic Premium plan. |
72 | | ->* The `Restore-AzDeletedWebApp` cmdlet restores a deleted web app. The web app specified by `TargetResourceGroupName`, `TargetName`, and `TargetSlot` is overwritten with the contents and settings of the deleted web app. If the target parameters aren't specified, they're automatically filled with the deleted web app's resource group, name, and slot. If the target web app doesn't exist, it's automatically created in the App Service plan specified by `TargetAppServicePlanName`. |
73 | | ->* By default `Restore-AzDeletedWebApp` restores both your app configuration and any content. If you want to only restore content, you use the `-RestoreContentOnly` flag with this cmdlet. |
74 | | ->* Custom domains, bindings, or certs that you import to your app aren't restored. You need to add them again after your app is restored. |
| 123 | +- If the target web app doesn't exist, the command creates a new app in the specified App Service plan. |
75 | 124 |
|
76 | | -After you identify the app you want to restore, you can restore it by using `Restore-AzDeletedWebApp`, as shown in the following examples. |
| 125 | +- By default, the command restores both your app configuration and any content. To restore the content only, use the `-RestoreContentOnly` flag. |
77 | 126 |
|
78 | | -You can find the full cmdlet reference here: [`Restore-AzDeletedWebApp`](/powershell/module/az.websites/restore-azdeletedwebapp). |
| 127 | +The following sections provide examples for using the `Restore-AzDeletedWebApp` command in different scenarios. Replace the various `<placeholder>` parameter values with the indicated information for your deleted app or the target app. |
79 | 128 |
|
80 | | -Restore to the original app name: |
| 129 | +#### Restore to the original app name |
81 | 130 |
|
82 | 131 | ```powershell |
83 | | -Restore-AzDeletedWebApp -TargetResourceGroupName <my_rg> -Name <my_app> -TargetAppServicePlanName <my_asp> |
| 132 | +Restore-AzDeletedWebApp -TargetResourceGroupName <target-resource-group> -Name <deleted-app-name> -TargetAppServicePlanName <target-app-service-plan> |
84 | 133 | ``` |
85 | 134 |
|
86 | | -Restore to a different app name: |
| 135 | +#### Restore to a different app name |
87 | 136 |
|
88 | 137 | ```powershell |
89 | | -Restore-AzDeletedWebApp -ResourceGroupName <original_rg> -Name <original_app> -TargetResourceGroupName <target_rg> -TargetName <target_app> -TargetAppServicePlanName <target_asp> |
| 138 | +Restore-AzDeletedWebApp -ResourceGroupName <deleted-app-resource-group> -Name <deleted-app-name> -TargetResourceGroupName <target-resource-group> -TargetName <target-app-name> -TargetAppServicePlanName <target-app-service-plan> |
90 | 139 | ``` |
91 | 140 |
|
92 | | -Restore a slot to the target app: |
| 141 | +#### Restore a slot to the target app |
93 | 142 |
|
94 | 143 | ```powershell |
95 | | -Restore-AzDeletedWebApp -TargetResourceGroupName <my_rg> -Name <my_app> -TargetAppServicePlanName <my_asp> -Slot <original_slot> |
| 144 | +Restore-AzDeletedWebApp -TargetResourceGroupName <target-resource-group> -Name <target-app-name> -TargetAppServicePlanName <target-app-service-plan> -Slot <deleted-app-slot> |
96 | 145 | ``` |
97 | 146 |
|
98 | 147 | > [!NOTE] |
99 | | -> Deployment slots aren't restored as part of your app. If you need to restore a staging slot, use the `-Slot <slot-name>` flag. |
100 | | -> The cmdlet restores the original slot to the target app's production slot. |
101 | | -> By default, `Restore-AzDeletedWebApp` restores both your app configuration as well any content to the target app. If you want to only restore content, you use the `-RestoreContentOnly` flag with this cmdlet. |
| 148 | +> Deployment slots aren't restored as part of your app. To restore a staging slot, use the `-Slot <slot-name>` flag. The command restores the original slot to the target app's production slot. |
102 | 149 |
|
103 | | -Restore only site content to the target app: |
| 150 | +#### Restore only site content to the target app |
104 | 151 |
|
105 | 152 | ```powershell |
106 | | -Restore-AzDeletedWebApp -TargetResourceGroupName <my_rg> -Name <my_app> -TargetAppServicePlanName <my_asp> -RestoreContentOnly |
| 153 | +Restore-AzDeletedWebApp -TargetResourceGroupName <target-resource-group> -Name <deleted-app-name> -TargetAppServicePlanName <target-app-service-plan> -RestoreContentOnly |
107 | 154 | ``` |
108 | 155 |
|
109 | | -Restore in scenarios where multiple apps with the same name were deleted with `-DeletedSiteId`: |
| 156 | +#### Restore when multiple deleted apps have same name (deleted site ID) |
110 | 157 |
|
111 | | -```powershell |
112 | | -Restore-AzDeletedWebApp -ResourceGroupName <original_rg> -Name <original_app> -DeletedId /subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/providers/Microsoft.Web/locations/location/deletedSites/1234 -TargetAppServicePlanName <my_asp> |
| 158 | +If multiple deleted apps have the same name, you can restore a specific app by specifying the site ID for the deleted app. |
| 159 | + |
| 160 | +The `Get-AzDeletedWebApp` command returns the deleted site ID for the app version. The site ID has the form `/subscriptions/<deleted-app-subscription>/providers/Microsoft.Web/locations/<deleted-app-location>/deletedSites/<deleted-app-site-ID>`. |
| 161 | + |
| 162 | +To restore the specific app, specify the deleted site ID: |
113 | 163 |
|
| 164 | +```powershell |
| 165 | +$deletedSite = Get-AzDeletedWebApp -ResourceGroupName <deleted-app-resource-group> -Name <deleted-app-name> |
| 166 | + |
| 167 | +Restore-AzDeletedWebApp -TargetResourceGroupName <target-app-resource-group> -TargetName <target-app-name> -TargetAppServicePlanName <target-app-service-plan> -InputObject $deletedSite[0] |
114 | 168 | ``` |
115 | 169 |
|
116 | | -The inputs for command are: |
| 170 | +--- |
117 | 171 |
|
118 | | -- **Target Resource Group**: Target resource group where the app will be restored. |
119 | | -- **TargetName**: Target app to which you're restoring the deleted app. |
120 | | -- **TargetAppServicePlanName**: App Service plan linked to the app. |
121 | | -- **Name**: Name for the app. We recommend that it's globally unique. |
122 | | -- **ResourceGroupName**: Original resource group for the deleted app. You can get it from `Get-AzDeletedWebApp -Name <your_deleted_app> -Location <your_deleted_app_location>`. |
123 | | -- **Slot**: Slot for the deleted app. |
124 | | -- **RestoreContentOnly**: By default `Restore-AzDeletedWebApp` restores both your app configuration as well any content. If you want to only restore content, you can use the `-RestoreContentOnly` flag with this cmdlet. |
| 172 | +## Restore a deleted Azure Functions app |
125 | 173 |
|
126 | | -## Restore deleted Azure Functions app |
| 174 | +If a function app hosted on a Dedicated App Service plan is deleted, you can restore the app, as long as it uses the default App Service storage. |
127 | 175 |
|
128 | | -If a function app was hosted on a Dedicated App Service plan, it can be restored, as long as it used the default App Service storage. |
| 176 | +### Restore an app in a Dedicated App Service plan |
129 | 177 |
|
130 | | -1. Fetch the `DeletedSiteId` of the app version you want to restore, by using the `Get-AzDeletedWebApp` cmdlet: |
| 178 | +To restore a function app in a new Dedicated App Service plan, follow the process to use the `Restore-AzDeletedWebApp` command, as described in [Restore when multiple deleted apps have same name (deleted site ID)](#restore-when-multiple-deleted-apps-have-same-name-deleted-site-id). For more information, see [Create a function app in the Azure portal](/azure/azure-functions/functions-create-function-app-portal#create-a-function-app). |
131 | 179 |
|
132 | | - ```powershell |
133 | | - Get-AzDeletedWebApp -ResourceGroupName <RGofDeletedApp> -Name <NameofApp> |
134 | | - ``` |
| 180 | +### Restore an app in a Consumption plan or Elastic premium plan |
135 | 181 |
|
136 | | -2. Create a new function app in a Dedicated plan. Refer to the instructions for [how to create an app in the portal](../azure-functions/functions-create-function-app-portal.md#create-a-function-app). Restore to the newly created function app by using this cmdlet: |
| 182 | +If the deleted function app is hosted in a Consumption plan or Elastic premium plan, you can't use the `Restore-AzDeletedWebApp` command. The operation isn't supported because the content resides on Azure Files in a storage account. |
137 | 183 |
|
138 | | - ```powershell |
139 | | - Restore-AzDeletedWebApp -ResourceGroupName <RGofnewapp> -Name <newApp> -deletedId "/subscriptions/xxxx/providers/Microsoft.Web/locations/xxxx/deletedSites/xxxx" |
140 | | - ``` |
| 184 | +A workaround is available, if you didn't hard delete the Azure Files storage account, or if the account exists and you didn't delete file shares. |
| 185 | + |
| 186 | +Follow these steps: |
| 187 | + |
| 188 | +1. Create a new function app in a Consumption or Premium plan. For more information, see [Create a function app in the Azure portal](/azure/azure-functions/functions-create-function-app-portal#create-a-function-app). |
| 189 | + |
| 190 | +1. Set the following [app settings](/azure/azure-functions/functions-how-to-use-azure-function-app-settings?tabs=portal#settings) to refer to the old storage account, which contains the content from the previous app. |
141 | 191 |
|
142 | | -Currently there's no support to use the `Restore-AzDeletedWebApp` cmdlet to undelete a function app hosted in a Consumption plan or Elastic premium plan, because the content resides on Azure Files in a storage account. If you didn't hard delete that Azure Files storage account, or if the account exists and you didn't delete file shares, you can use the following steps as a workaround: |
| 192 | + | App setting | Suggested value | |
| 193 | + |---|---| |
| 194 | + | `AzureWebJobsStorage` | Connection string for the storage account used by the deleted app. | |
| 195 | + | `WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` | Connection string for the storage account used by the deleted app. | |
| 196 | + | `WEBSITE_CONTENTSHARE` | File share on storage account used by the deleted app. | |
143 | 197 |
|
144 | | -1. Create a new function app in a Consumption or Premium plan. Refer the instructions for [how to create an app in the portal](../azure-functions/functions-create-function-app-portal.md#create-a-function-app). |
145 | | -1. Set the following [app settings](../azure-functions/functions-how-to-use-azure-function-app-settings.md?tabs=portal#settings) to refer to the old storage account, which contains the content from the previous app. |
| 198 | +## Related content |
146 | 199 |
|
147 | | - | App setting | Suggested value | |
148 | | - | ------------ | ---------------- | |
149 | | - | `AzureWebJobsStorage` | Connection string for the storage account used by the deleted app | |
150 | | - | `WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` | Connection string for the storage account used by the deleted app | |
151 | | - | `WEBSITE_CONTENTSHARE` | File share on storage account used by the deleted app | |
| 200 | +- [Get-AzDeletedWebApp](/powershell/module/az.websites/get-azdeletedwebapp) command reference |
| 201 | +- [Restore-AzDeletedWebApp](/powershell/module/az.websites/restore-azdeletedwebapp) command reference |
0 commit comments