Skip to content

Commit 084c498

Browse files
author
Maddie Clayton
authored
Merge pull request Azure#8989 from Nking92/WebAppsDisasterRecovery
Add -UseDisasterRecovery parameter to WebApps Restore cmdlets
2 parents c051ba8 + 582261a commit 084c498

17 files changed

+9475
-8615
lines changed

src/Websites/Websites.Test/ScenarioTests/WebAppBackupRestoreTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public WebAppBackupRestoreTests(ITestOutputHelper output)
3131
}
3232

3333
#if NETSTANDARD
34-
[Fact(Skip = "Storage version out-of-date: Awaiting Storage.Management.Common")]
34+
[Fact]
3535
[Trait(Category.RunType, Category.DesktopOnly)]
3636
#else
3737
[Fact]
@@ -43,7 +43,7 @@ public void TestCreateNewWebAppBackup()
4343
}
4444

4545
#if NETSTANDARD
46-
[Fact(Skip = "Storage version out-of-date: Awaiting Storage.Management.Common")]
46+
[Fact]
4747
[Trait(Category.RunType, Category.DesktopOnly)]
4848
#else
4949
[Fact]
@@ -55,7 +55,7 @@ public void TestCreateNewWebAppBackupPiping()
5555
}
5656

5757
#if NETSTANDARD
58-
[Fact(Skip = "Storage version out-of-date: Awaiting Storage.Management.Common")]
58+
[Fact]
5959
[Trait(Category.RunType, Category.DesktopOnly)]
6060
#else
6161
[Fact]
@@ -67,7 +67,7 @@ public void TestGetWebAppBackup()
6767
}
6868

6969
#if NETSTANDARD
70-
[Fact(Skip = "Storage version out-of-date: Awaiting Storage.Management.Common")]
70+
[Fact]
7171
[Trait(Category.RunType, Category.DesktopOnly)]
7272
#else
7373
[Fact]
@@ -79,7 +79,7 @@ public void TestGetWebAppBackupList()
7979
}
8080

8181
#if NETSTANDARD
82-
[Fact(Skip = "Storage version out-of-date: Awaiting Storage.Management.Common")]
82+
[Fact]
8383
[Trait(Category.RunType, Category.DesktopOnly)]
8484
#else
8585
[Fact]
@@ -91,7 +91,7 @@ public void TestEditAndGetWebAppBackupConfiguration()
9191
}
9292

9393
#if NETSTANDARD
94-
[Fact(Skip = "Storage version out-of-date: Awaiting Storage.Management.Common")]
94+
[Fact]
9595
[Trait(Category.RunType, Category.DesktopOnly)]
9696
#else
9797
[Fact]
@@ -116,21 +116,21 @@ public void TestRestoreWebAppSnapshot()
116116
WebsitesController.NewInstance.RunPsTest(_logger, "Test-RestoreWebAppSnapshot");
117117
}
118118

119-
[Fact(Skip = "Failing test, Investigation needed")]
119+
[Fact]
120120
[Trait(Category.AcceptanceType, Category.CheckIn)]
121121
public void TestGetDeletedWebApp()
122122
{
123123
WebsitesController.NewInstance.RunPsTest(_logger, "Test-GetDeletedWebApp");
124124
}
125125

126-
[Fact(Skip = "Needs re-recorded, Restore tests use prior webapp state on the subscription")]
126+
[Fact]
127127
[Trait(Category.AcceptanceType, Category.CheckIn)]
128128
public void TestRestoreDeletedWebAppToExisting()
129129
{
130130
WebsitesController.NewInstance.RunPsTest(_logger, "Test-RestoreDeletedWebAppToExisting");
131131
}
132132

133-
[Fact(Skip = "Failing test, Investigation needed")]
133+
[Fact]
134134
[Trait(Category.AcceptanceType, Category.CheckIn)]
135135
public void TestRestoreDeletedWebAppToNew()
136136
{

src/Websites/Websites.Test/ScenarioTests/WebAppBackupRestoreTests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
# Snapshots require a Premium app to exist for several hours.
1616
# Deploy a Premium app and update these global variables to re-record the snapshots tests.
17-
$snapshotRgName = 'onesdksnapshots'
18-
$snapshotAppName = 'onesdkpremapp2'
17+
$snapshotRgName = 'web2'
18+
$snapshotAppName = 'nkprem'
1919
$snapshotAppSlot = 'staging'
2020

2121
# Restoring a deleted web app requires an app to have a snapshot available.
2222
# Deploy a web app and wait at least an hour for a snapshot.
2323
# Update these global variables to re-record Test-RestoreDeletedWebApp.
24-
$undeleteRgName = 'ps8425'
25-
$undeleteAppName = 'ps1705'
24+
$undeleteRgName = 'nickingssltests'
25+
$undeleteAppName = 'nkundeletetest'
2626
$undeleteSlot = 'testslot'
2727

2828
# !!! Storage keys and SAS URIs will be stored in the backup test recordings !!!
@@ -379,7 +379,7 @@ function Test-RestoreWebAppSnapshot
379379
Restore-AzWebAppSnapshot -ResourceGroupName $snapshotRgName -Name $snapshotAppName -InputObject $snapshot -Force -RecoverConfiguration
380380

381381
# Test restore to target slot
382-
Restore-AzWebAppSnapshot $snapshotRgName $snapshotAppName $snapshotAppSlot $snapshot -RecoverConfiguration -Force
382+
Restore-AzWebAppSnapshot $snapshotRgName $snapshotAppName $snapshotAppSlot $snapshot -RecoverConfiguration -UseDisasterRecovery -Force
383383

384384
# Test piping and background job
385385
$job = $snapshot | Restore-AzWebAppSnapshot -Force -AsJob
@@ -482,7 +482,7 @@ function Test-RestoreDeletedWebAppToNew
482482
New-AzAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $location -Tier $tier
483483
$deletedApp = Get-AzDeletedWebApp -ResourceGroupName $undeleteRgName -Name $undeleteAppName -Slot "Production"
484484
# Test piping the deleted app
485-
$job = $deletedApp | Restore-AzDeletedWebApp -TargetResourceGroupName $rgname -TargetAppServicePlanName $whpName -Force -AsJob
485+
$job = $deletedApp | Restore-AzDeletedWebApp -TargetResourceGroupName $rgname -TargetAppServicePlanName $whpName -UseDisasterRecovery -Force -AsJob
486486
$result = $job | Wait-Job
487487
Assert-AreEqual "Completed" $result.State;
488488

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

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

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

Lines changed: 821 additions & 884 deletions
Large diffs are not rendered by default.

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

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

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

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

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

Lines changed: 916 additions & 784 deletions
Large diffs are not rendered by default.

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

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

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

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

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

Lines changed: 323 additions & 254 deletions
Large diffs are not rendered by default.

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

Lines changed: 1709 additions & 1301 deletions
Large diffs are not rendered by default.

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

Lines changed: 772 additions & 637 deletions
Large diffs are not rendered by default.

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

Lines changed: 837 additions & 696 deletions
Large diffs are not rendered by default.

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public class RestoreAzureDeletedWebApp : WebAppBaseClientCmdLet
6060
[Parameter(Mandatory = false, HelpMessage = "Restore the web app's files, but do not restore the settings.")]
6161
public SwitchParameter RestoreContentOnly { get; set; }
6262

63+
[Parameter(Mandatory = false, HelpMessage = "Use to recover a deleted app from a scale unit that is offline.")]
64+
public SwitchParameter UseDisasterRecovery { get; set; }
65+
6366
[Parameter(Mandatory = false, HelpMessage = "Do the restore without prompting for confirmation.")]
6467
public SwitchParameter Force { get; set; }
6568

@@ -76,7 +79,8 @@ public override void ExecuteCmdlet()
7679
DeletedAppRestoreRequest restoreReq = new DeletedAppRestoreRequest()
7780
{
7881
DeletedSiteId = deletedSiteId,
79-
RecoverConfiguration = !this.RestoreContentOnly
82+
RecoverConfiguration = !this.RestoreContentOnly,
83+
UseDRSecondary = UseDisasterRecovery
8084
};
8185

8286
Action restoreAction = () => WebsitesClient.RestoreDeletedWebApp(TargetResourceGroupName, TargetName, TargetSlot, restoreReq);

src/Websites/Websites/Cmdlets/BackupRestore/RestoreAzureWebAppSnapshot.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public class RestoreAzureWebAppSnapshot : WebAppOptionalSlotBaseCmdlet
3939
[Parameter(Mandatory = false, HelpMessage = "Recover the web app's configuration in addition to files.", ValueFromPipelineByPropertyName = true)]
4040
public SwitchParameter RecoverConfiguration { get; set; }
4141

42+
[Parameter(Mandatory = false, HelpMessage = "Use to recover a snapshot from a scale unit that is offline.")]
43+
public SwitchParameter UseDisasterRecovery { get; set; }
44+
4245
[Parameter(Mandatory = false, HelpMessage = "Allows the original web app to be overwritten without displaying a warning.", ValueFromPipelineByPropertyName = true)]
4346
public SwitchParameter Force { get; set; }
4447

@@ -60,7 +63,8 @@ public override void ExecuteCmdlet()
6063
SnapshotTime = this.InputObject.SnapshotTime.ToString("o"),
6164
RecoverConfiguration = this.RecoverConfiguration,
6265
IgnoreConflictingHostNames = true,
63-
RecoverySource = source
66+
RecoverySource = source,
67+
UseDRSecondary = UseDisasterRecovery
6468
};
6569
Action recoverAction = () => WebsitesClient.RestoreSnapshot(ResourceGroupName, Name, Slot, recoveryReq);
6670
ConfirmAction(this.Force.IsPresent, "Web app contents will be overwritten with the contents of the snapshot.",

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
external help file: Microsoft.Azure.PowerShell.Cmdlets.Websites.dll-Help.xml
33
Module Name: Az.Websites
44
online version: https://docs.microsoft.com/en-us/powershell/module/az.websites/restore-azdeletedwebapp
@@ -16,14 +16,14 @@ Restores a deleted web app to a new or existing web app.
1616
```
1717
Restore-AzDeletedWebApp [-ResourceGroupName] <String> [-Name] <String> [[-Slot] <String>]
1818
[-TargetResourceGroupName <String>] [-TargetName <String>] [-TargetSlot <String>]
19-
[-TargetAppServicePlanName <String>] [-RestoreContentOnly] [-Force] [-AsJob]
19+
[-TargetAppServicePlanName <String>] [-RestoreContentOnly] [-UseDisasterRecovery] [-Force] [-AsJob]
2020
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2121
```
2222

2323
### FromDeletedApp
2424
```
2525
Restore-AzDeletedWebApp [-TargetResourceGroupName <String>] [-TargetName <String>] [-TargetSlot <String>]
26-
[-TargetAppServicePlanName <String>] [-RestoreContentOnly] [-Force] [-AsJob]
26+
[-TargetAppServicePlanName <String>] [-RestoreContentOnly] [-UseDisasterRecovery] [-Force] [-AsJob]
2727
[-DefaultProfile <IAzureContextContainer>] [-InputObject] <PSAzureDeletedWebApp> [-WhatIf] [-Confirm]
2828
[<CommonParameters>]
2929
```
@@ -229,6 +229,21 @@ Accept pipeline input: False
229229
Accept wildcard characters: False
230230
```
231231
232+
### -UseDisasterRecovery
233+
Use to recover a deleted app from a scale unit that is offline.
234+
235+
```yaml
236+
Type: System.Management.Automation.SwitchParameter
237+
Parameter Sets: (All)
238+
Aliases:
239+
240+
Required: False
241+
Position: Named
242+
Default value: None
243+
Accept pipeline input: False
244+
Accept wildcard characters: False
245+
```
246+
232247
### -Confirm
233248
Prompts you for confirmation before running the cmdlet.
234249

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
external help file: Microsoft.Azure.PowerShell.Cmdlets.Websites.dll-Help.xml
33
Module Name: Az.Websites
44
online version: https://docs.microsoft.com/en-us/powershell/module/az.websites/restore-azwebappsnapshot
@@ -14,14 +14,14 @@ Restores a web app snapshot.
1414

1515
### FromResourceName
1616
```
17-
Restore-AzWebAppSnapshot [-RecoverConfiguration] [-Force] [-AsJob] [-ResourceGroupName] <String>
18-
[-Name] <String> [[-Slot] <String>] [-DefaultProfile <IAzureContextContainer>]
17+
Restore-AzWebAppSnapshot [-RecoverConfiguration] [-UseDisasterRecovery] [-Force] [-AsJob]
18+
[-ResourceGroupName] <String> [-Name] <String> [[-Slot] <String>] [-DefaultProfile <IAzureContextContainer>]
1919
[-InputObject] <AzureWebAppSnapshot> [-WhatIf] [-Confirm] [<CommonParameters>]
2020
```
2121

2222
### FromWebApp
2323
```
24-
Restore-AzWebAppSnapshot [-RecoverConfiguration] [-Force] [-AsJob] [-WebApp] <PSSite>
24+
Restore-AzWebAppSnapshot [-RecoverConfiguration] [-UseDisasterRecovery] [-Force] [-AsJob] [-WebApp] <PSSite>
2525
[-DefaultProfile <IAzureContextContainer>] [-InputObject] <AzureWebAppSnapshot> [-WhatIf] [-Confirm]
2626
[<CommonParameters>]
2727
```
@@ -161,6 +161,21 @@ Accept pipeline input: True (ByPropertyName)
161161
Accept wildcard characters: False
162162
```
163163
164+
### -UseDisasterRecovery
165+
Use to recover a snapshot from a scale unit that is offline.
166+
167+
```yaml
168+
Type: System.Management.Automation.SwitchParameter
169+
Parameter Sets: (All)
170+
Aliases:
171+
172+
Required: False
173+
Position: Named
174+
Default value: None
175+
Accept pipeline input: False
176+
Accept wildcard characters: False
177+
```
178+
164179
### -WebApp
165180
The web app object
166181

0 commit comments

Comments
 (0)