|
1 | 1 | ---
|
2 |
| -title: Restore deleted apps |
| 2 | +title: Restore Deleted Apps |
3 | 3 | description: Learn how to restore a deleted app in Azure App Service. Avoid the headache of an accidentally deleted app.
|
4 | 4 | author: seligj95
|
5 | 5 | ms.author: jordanselig
|
6 | 6 | ms.date: 10/4/2023
|
7 |
| -ms.topic: article |
| 7 | +ms.topic: how-to |
8 | 8 | ms.custom: devx-track-azurepowershell
|
9 | 9 | ---
|
10 |
| -# Restore deleted App Service app |
11 | 10 |
|
12 |
| -If you happened to accidentally delete your app in Azure App Service, you can now restore it by using the Azure portal or PowerShell. |
| 11 | +# Restore a deleted App Service app |
13 | 12 |
|
14 |
| -## Restore deleted App Service app by using the portal |
| 13 | +If you accidentally deleted an app in Azure App Service, you can now restore it by using the Azure portal or PowerShell. |
15 | 14 |
|
16 |
| -If you deleted your app in Azure App Service, you can now restore it from the portal by using following steps: |
| 15 | +## Restore a deleted App Service app by using the Azure portal |
17 | 16 |
|
18 |
| -1. Navigate to App Services in the portal. |
19 |
| -1. Click on **Manage Deleted Apps**. |
| 17 | +If you deleted your app in Azure App Service, you can restore it from the portal by following these steps: |
| 18 | + |
| 19 | +1. Go to **App Services** in the Azure portal. |
| 20 | +1. Select **Manage Deleted Apps**. |
20 | 21 | 1. Select **Subscription**.
|
21 |
| -1. From the dropdown, select the deleted app. Apps deleted in last 30 days will show up in the drop down list. |
22 |
| -1. Select destination app from the dropdown where you want to restore your app. |
23 |
| -1. If you would like to restore the deleted app to a slot of destination app, check the slot checkbox and select available slots from the dropdown. |
24 |
| -1. By default only app content is restored. If you want app configuration also to be restored, check **Restore App configuration**. |
| 22 | +1. From the dropdown list, select the deleted app. Apps that were deleted in the last 30 days appear in the list. |
| 23 | +1. Select the destination app from the dropdown list that correlates to where you want to restore your app. |
| 24 | +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. |
| 25 | +1. By default, only app content is restored. If you want app configuration to also be restored, select **Restore App configuration**. |
25 | 26 |
|
26 |
| -## Restore deleted App Service app by using PowerShell |
| 27 | +## Restore a deleted App Service app by using PowerShell |
27 | 28 |
|
28 |
| -If you deleted your app in Azure App Service, you can restore it using the commands from the [Az PowerShell module](/powershell/azure/). |
| 29 | +If you deleted your app in Azure App Service, you can restore it by using the commands from the [`Az PowerShell module`](/powershell/azure/). |
29 | 30 |
|
30 | 31 | > [!NOTE]
|
31 |
| -> - Deleted apps are purged from the system 30 days after the initial deletion. After an app is purged, it can't be recovered. |
32 |
| -> - Undelete functionality isn't supported for function apps hosted on the Consumption plan or Elastic Premium plan. |
33 |
| -
|
| 32 | +> * Deleted apps are purged from the system 30 days after the initial deletion. After an app is purged, it can't be recovered. |
| 33 | +> * Undelete functionality isn't supported for function apps hosted on the Consumption plan or Elastic Premium plan. |
34 | 34 |
|
35 | 35 | ## Re-register App Service resource provider
|
36 | 36 |
|
37 |
| -Some customers might come across an issue where retrieving the list of deleted apps fails. To resolve the issue, run the following command: |
| 37 | +Some customers might experience failure to retrieve the list of deleted apps. To resolve the issue, run the following command: |
38 | 38 |
|
39 | 39 | ```powershell
|
40 | 40 | Register-AzResourceProvider -ProviderNamespace "Microsoft.Web"
|
41 | 41 | ```
|
42 | 42 |
|
43 | 43 | ## List deleted apps
|
44 | 44 |
|
45 |
| -To get the collection of deleted apps, you can use `Get-AzDeletedWebApp`. |
| 45 | +To access the collection of deleted apps, you can use `Get-AzDeletedWebApp`. |
46 | 46 |
|
47 |
| -For details on a specific deleted app you can use: |
| 47 | +To get details on a specific deleted app, you can use: |
48 | 48 |
|
49 | 49 | ```powershell
|
50 | 50 | Get-AzDeletedWebApp -Name <your_deleted_app> -Location <your_deleted_app_location>
|
51 | 51 | ```
|
52 | 52 |
|
53 | 53 | The detailed information includes:
|
54 | 54 |
|
55 |
| -- **DeletedSiteId**: Unique identifier for the app, used for scenarios where multiple apps with the same name have been deleted |
56 |
| -- **SubscriptionID**: Subscription containing the deleted resource |
57 |
| -- **Location**: Location of the original app |
58 |
| -- **ResourceGroupName**: Name of the original resource group |
59 |
| -- **Name**: Name of the original app. |
60 |
| -- **Slot**: the name of the slot. |
61 |
| -- **Deletion Time**: When was the app deleted |
| 55 | +* **DeletedSiteId**: Unique identifier for the app, used for scenarios where multiple apps with the same name were deleted. |
| 56 | +* **SubscriptionID**: Subscription that contains the deleted resource. |
| 57 | +* **Location**: Location of the original app. |
| 58 | +* **ResourceGroupName**: Name of the original resource group. |
| 59 | +* **Name**: Name of the original app. |
| 60 | +* **Slot**: Name of the slot. |
| 61 | +* **Deletion Time**: When the app was deleted. |
62 | 62 |
|
63 | 63 | ## Restore deleted app
|
64 | 64 |
|
65 | 65 | >[!NOTE]
|
66 |
| ->- `Restore-AzDeletedWebApp` isn't supported for function apps hosted on the Consumption plan or Elastic Premium plan. |
67 |
| ->- The Restore-AzDeletedWebApp cmdlet restores a deleted web app. The web app specified by TargetResourceGroupName, TargetName, and TargetSlot will be overwritten with the contents and settings of the deleted web app. If the target parameters are not specified, they will automatically be filled with the deleted web app's resource group, name, and slot. If the target web app does not exist, it will automatically be created in the app service plan specified by TargetAppServicePlanName. |
68 |
| ->- By default `Restore-AzDeletedWebApp` will restore both your app configuration as well any content. If you want to only restore content, you use the **`-RestoreContentOnly`** flag with this commandlet. |
69 |
| ->- Custom domains, bindings, or certs that you import to your app won't be restored. You'll need to re-add them after your app is restored. |
| 66 | +> |
| 67 | +>* `Restore-AzDeletedWebApp` isn't supported for function apps hosted on the Consumption plan or Elastic Premium plan. |
| 68 | +>* 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`. |
| 69 | +>* 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. |
| 70 | +>* 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. |
| 71 | +
|
| 72 | +After you identify the app you want to restore, you can restore it by using `Restore-AzDeletedWebApp`, as shown in the following examples. |
70 | 73 |
|
| 74 | +You can find the full cmdlet reference here: [`Restore-AzDeletedWebApp`](/powershell/module/az.websites/restore-azdeletedwebapp). |
71 | 75 |
|
72 |
| -After identifying the app you want to restore, you can restore it using `Restore-AzDeletedWebApp`, as shown in the following examples. |
73 |
| ->*You can find the full commandlet reference here: **[Restore-AzDeletedWebApp](/powershell/module/az.websites/restore-azdeletedwebapp)*** . |
| 76 | +Restore to the original app name: |
74 | 77 |
|
75 |
| ->Restore to the original app name: |
76 | 78 | ```powershell
|
77 | 79 | Restore-AzDeletedWebApp -TargetResourceGroupName <my_rg> -Name <my_app> -TargetAppServicePlanName <my_asp>
|
78 | 80 | ```
|
79 | 81 |
|
80 |
| ->Restore to a different app name: |
| 82 | +Restore to a different app name: |
| 83 | + |
81 | 84 | ```powershell
|
82 | 85 | Restore-AzDeletedWebApp -ResourceGroupName <original_rg> -Name <original_app> -TargetResourceGroupName <target_rg> -TargetName <target_app> -TargetAppServicePlanName <target_asp>
|
83 | 86 | ```
|
84 | 87 |
|
85 |
| ->Restore a slot to target app: |
| 88 | +Restore a slot to the target app: |
| 89 | + |
86 | 90 | ```powershell
|
87 | 91 | Restore-AzDeletedWebApp -TargetResourceGroupName <my_rg> -Name <my_app> -TargetAppServicePlanName <my_asp> -Slot <original_slot>
|
88 | 92 | ```
|
89 | 93 |
|
90 | 94 | > [!NOTE]
|
91 |
| -> Deployment slots are not restored as part of your app. If you need to restore a staging slot, use the `-Slot <slot-name>` flag. |
92 |
| -> The commandlet is restoring original slot to the target app's production slot. |
93 |
| -> By default `Restore-AzDeletedWebApp` will restore both your app configuration as well any content to target app. If you want to only restore content, you use the `-RestoreContentOnly` flag with this commandlet. |
| 95 | +> Deployment slots aren't restored as part of your app. If you need to restore a staging slot, use the `-Slot <slot-name>` flag. |
| 96 | +> The cmdlet restores the original slot to the target app's production slot. |
| 97 | +> 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. |
| 98 | +
|
| 99 | +Restore only site content to the target app: |
94 | 100 |
|
95 |
| ->Restore only site content to the target app |
96 | 101 | ```powershell
|
97 | 102 | Restore-AzDeletedWebApp -TargetResourceGroupName <my_rg> -Name <my_app> -TargetAppServicePlanName <my_asp> -RestoreContentOnly
|
98 | 103 | ```
|
99 | 104 |
|
100 |
| ->Restore used for scenarios where multiple apps with the same name have been deleted with `-DeletedSiteId` |
| 105 | +Restore in scenarios where multiple apps with the same name were deleted with `-DeletedSiteId`: |
| 106 | + |
101 | 107 | ```powershell
|
102 | 108 | 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>
|
103 | 109 |
|
104 | 110 | ```
|
105 | 111 |
|
106 | 112 | The inputs for command are:
|
107 | 113 |
|
108 |
| -- **Target Resource Group**: Target resource group where the app is to be restored |
109 |
| -- **TargetName**: Target app for the deleted app to be restored to |
110 |
| -- **TargetAppServicePlanName**: App Service plan linked to the app |
111 |
| -- **Name**: Name for the app, should be globally unique. |
112 |
| -- **ResourceGroupName**: Original resource group for the deleted app, you can get it from Get-AzDeletedWebApp -Name <your_deleted_app> -Location <your_deleted_app_location> |
113 |
| -- **Slot**: Slot for the deleted app |
114 |
| -- **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 commandlet. |
| 114 | +- **Target Resource Group**: Target resource group where the app will be restored. |
| 115 | +- **TargetName**: Target app to which you're restoring the deleted app. |
| 116 | +- **TargetAppServicePlanName**: App Service plan linked to the app. |
| 117 | +- **Name**: Name for the app. We recommend that it's globally unique. |
| 118 | +- **ResourceGroupName**: Original resource group for the deleted app. You can get it from `Get-AzDeletedWebApp -Name <your_deleted_app> -Location <your_deleted_app_location>`. |
| 119 | +- **Slot**: Slot for the deleted app. |
| 120 | +- **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. |
115 | 121 |
|
116 | 122 | > [!NOTE]
|
117 | 123 | > 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.
|
118 | 124 |
|
119 |
| -## Restore deleted function app |
| 125 | +## Restore deleted Azure Functions app |
120 | 126 |
|
121 |
| -If the function app was hosted on a **Dedicated app service plan**, it can be restored, as long as it was using the default App Service storage. |
| 127 | +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. |
122 | 128 |
|
123 |
| -1. Fetch the DeletedSiteId of the app version you want to restore, using Get-AzDeletedWebApp cmdlet: |
| 129 | +1. Fetch the `DeletedSiteId` of the app version you want to restore, by using the `Get-AzDeletedWebApp` cmdlet: |
124 | 130 |
|
125 |
| -```powershell |
126 |
| -Get-AzDeletedWebApp -ResourceGroupName <RGofDeletedApp> -Name <NameofApp> |
127 |
| -``` |
128 |
| -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). |
129 |
| -3. Restore to the newly created function app using this cmdlet: |
| 131 | + ```powershell |
| 132 | + Get-AzDeletedWebApp -ResourceGroupName <RGofDeletedApp> -Name <NameofApp> |
| 133 | + ``` |
130 | 134 |
|
131 |
| -```powershell |
132 |
| -Restore-AzDeletedWebApp -ResourceGroupName <RGofnewapp> -Name <newApp> -deletedId "/subscriptions/xxxx/providers/Microsoft.Web/locations/xxxx/deletedSites/xxxx" |
133 |
| -``` |
| 135 | +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: |
| 136 | + |
| 137 | + ```powershell |
| 138 | + Restore-AzDeletedWebApp -ResourceGroupName <RGofnewapp> -Name <newApp> -deletedId "/subscriptions/xxxx/providers/Microsoft.Web/locations/xxxx/deletedSites/xxxx" |
| 139 | + ``` |
134 | 140 |
|
135 |
| -Currently there's no support for Undelete (Restore-AzDeletedWebApp) Function app that's hosted in a Consumption plan or Elastic premium plan since the content resides on Azure Files in a Storage account. If you haven't 'hard' deleted that Azure Files storage account, or if the account exists and file shares haven't been deleted, then you may use the steps as workaround: |
136 |
| - |
| 141 | +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: |
137 | 142 |
|
138 | 143 | 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).
|
139 |
| -2. 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. |
| 144 | +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. |
140 | 145 |
|
141 |
| - | App Setting | Suggested value | |
142 |
| - | ------------ | ---------------- | |
143 |
| - | **AzureWebJobsStorage** | Connection String for the storage account used by the deleted app. | |
144 |
| - | **WEBSITE_CONTENTAZUREFILECONNECTIONSTRING** | Connection String for the storage account used by the deleted app. | |
145 |
| - | **WEBSITE_CONTENTSHARE** | File share on storage account used by the deleted app. | |
| 146 | + | App setting | Suggested value | |
| 147 | + | ------------ | ---------------- | |
| 148 | + | `AzureWebJobsStorage` | Connection string for the storage account used by the deleted app | |
| 149 | + | `WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` | Connection string for the storage account used by the deleted app | |
| 150 | + | `WEBSITE_CONTENTSHARE` | File share on storage account used by the deleted app | |
0 commit comments