Skip to content

Commit 959f1f3

Browse files
[App Service]: Added support to use Id for Restore-AzDeletedWebApp. (#12256)
* Git #11895 and #5983 * Fix for #12015- Set-AzWebAppSlot incorrectly formats serverFarmId causing Service Plan not found error * Updated ChangeLog.md * Fix for #12015- Set-AzWebAppSlot incorrectly formats serverFarmId causing Service Plan not found error * fix #11862 - Added support to use Id for Restore-AzDeletedWebApp.
1 parent ab8b080 commit 959f1f3

File tree

6 files changed

+3889
-2938
lines changed

6 files changed

+3889
-2938
lines changed

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests/TestRestoreDeletedWebAppToExisting.json

Lines changed: 2712 additions & 1810 deletions
Large diffs are not rendered by default.

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests/TestRestoreDeletedWebAppToNew.json

Lines changed: 1142 additions & 1123 deletions
Large diffs are not rendered by default.

src/Websites/Websites/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
* Fixed bug to get SiteConfig when -Name is not given for Get-AzWebApp
2828
* Added a support to create ASP for Linux Apps
2929
* Added exceptions for clone across resource groups
30+
* Added support to perform operations for Slots not in the same resource group as the App Service Plan
31+
* Added support to use Id for Restore-AzDeletedWebApp.
3032

3133
## Version 1.9.0
3234
* Fixed typo on help of `Update-AzWebAppAccessRestrictionConfig`.

src/Websites/Websites/Cmdlets/BackupRestore/PSAzureDeletedWebApp.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps
1919
{
2020
public class PSAzureDeletedWebApp
2121
{
22+
public string Id { get; private set; }
2223
public int DeletedSiteId { get; set; }
2324

2425
public string SubscriptionId { get; set; }
@@ -35,6 +36,7 @@ public class PSAzureDeletedWebApp
3536

3637
public PSAzureDeletedWebApp(DeletedSite ds, string subscriptionId)
3738
{
39+
Id = ds.Id;
3840
DeletedSiteId = ds.DeletedSiteId.Value;
3941
DeletionTime = DateTime.Parse(ds.DeletedTimestamp, System.Globalization.CultureInfo.InvariantCulture);
4042
SubscriptionId = subscriptionId;

src/Websites/Websites/Cmdlets/BackupRestore/RestoreAzureDeletedWebApp.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public class RestoreAzureDeletedWebApp : WebAppBaseClientCmdLet
4949
[Parameter(ParameterSetName = FromDeletedResourceNameParameterSet, Mandatory = false, HelpMessage = "The location of the deleted Azure Web App.")]
5050
public string Location { get; set; }
5151

52+
[Parameter(ParameterSetName = FromDeletedResourceNameParameterSet, Mandatory = false, HelpMessage = "The Resource ID of the deleted web app.")]
53+
public string DeletedId { get; set; }
54+
5255
[Parameter(Mandatory = false, HelpMessage = "The resource group containing the new Azure Web App.")]
5356
public string TargetResourceGroupName { get; set; }
5457

@@ -77,7 +80,7 @@ public override void ExecuteCmdlet()
7780
{
7881
base.ExecuteCmdlet();
7982

80-
string deletedSiteId = GetDeletedSiteResourceId();
83+
string deletedSiteId = string.IsNullOrEmpty(DeletedId) ? GetDeletedSiteResourceId() : DeletedId;
8184
ResolveTargetParameters();
8285

8386
DeletedAppRestoreRequest restoreReq = new DeletedAppRestoreRequest()

src/Websites/Websites/help/Restore-AzDeletedWebApp.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ Restores a deleted web app to a new or existing web app.
1515
### FromDeletedResourceName (Default)
1616
```
1717
Restore-AzDeletedWebApp [-ResourceGroupName] <String> [-Name] <String> [[-Slot] <String>] [-Location <String>]
18-
[-TargetResourceGroupName <String>] [-TargetName <String>] [-TargetSlot <String>]
18+
[-DeletedId <String>] [-TargetResourceGroupName <String>] [-TargetName <String>] [-TargetSlot <String>]
1919
[-TargetAppServicePlanName <String>] [-RestoreContentOnly] [-UseDisasterRecovery] [-Force] [-AsJob]
2020
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2121
```
2222

2323
### FromDeletedApp
2424
```
25-
Restore-AzDeletedWebApp [-TargetResourceGroupName <String>] [-TargetName <String>] [-TargetSlot <String>]
26-
[-TargetAppServicePlanName <String>] [-RestoreContentOnly] [-UseDisasterRecovery] [-Force] [-AsJob]
27-
[-DefaultProfile <IAzureContextContainer>] [-InputObject] <PSAzureDeletedWebApp> [-WhatIf] [-Confirm]
25+
Restore-AzDeletedWebApp [-TargetResourceGroupName <String>] [-DeletedId <String>] [-TargetName <String>]
26+
[-TargetSlot <String>] [-TargetAppServicePlanName <String>] [-RestoreContentOnly] [-UseDisasterRecovery]
27+
[-Force] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-InputObject] <PSAzureDeletedWebApp>
28+
[-WhatIf] [-Confirm]
2829
[<CommonParameters>]
2930
```
3031

@@ -49,6 +50,13 @@ Restores the Staging slot of a deleted app named ContosoApp belonging to the res
4950

5051
###Example 3
5152
```powershell
53+
PS C:\> Restore-AzDeletedWebApp -ResourceGroupName Default-Web-WestUS -Name ContosoApp -DeletedId /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/locations/location/deletedSites/1234 -TargetAppServicePlanName ContosoPlan
54+
```
55+
56+
In case there are 2 deleted apps with same name(ContosoApp), then we get details of both the sites and restore the app named ContosoRestore with the app of our choice by calling restore with Id.
57+
58+
###Example 4
59+
```powershell
5260
PS C:\> $deletedSite = Get-AzDeletedWebApp -ResourceGroupName Default-Web-WestUS -Name ContosoApp
5361
PS C:\> Restore-AzDeletedWebApp -TargetResourceGroupName Default-Web-EastUS -TargetName ContosoRestore -TargetAppServicePlanName ContosoPlan -InputObject $deletedSite[0]
5462
```
@@ -87,6 +95,21 @@ Accept pipeline input: False
8795
Accept wildcard characters: False
8896
```
8997
98+
### -DeletedId
99+
The Id of the deleted Azure Web App.
100+
101+
```yaml
102+
Type: System.String
103+
Parameter Sets: FromDeletedResourceName
104+
Aliases:
105+
106+
Required: False
107+
Position: Named
108+
Default value: None
109+
Accept pipeline input: False
110+
Accept wildcard characters: False
111+
```
112+
90113
### -Force
91114
Do the restore without prompting for confirmation.
92115

0 commit comments

Comments
 (0)