Skip to content

Commit 8a0c6c5

Browse files
authored
Merge pull request #4876 from Nking92/preview
[WebSites] Fix broken Restore Backup command, add Snapshots commands, update client SDK
2 parents 7113b48 + c98f6e5 commit 8a0c6c5

File tree

117 files changed

+212740
-20113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+212740
-20113
lines changed

src/ResourceManager/Websites/AzureRM.Websites.Netcore.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ CmdletsToExport = 'Get-AzureRmAppServicePlan', 'Set-AzureRmAppServicePlan',
9393
'New-AzureRmWebAppBackup', 'Remove-AzureRmWebApp',
9494
'New-AzureRmWebApp', 'Remove-AzureRmWebAppBackup',
9595
'Reset-AzureRmWebAppPublishingProfile', 'Restart-AzureRmWebApp',
96-
'Set-AzureRmWebApp', 'Start-AzureRmWebApp', 'Stop-AzureRmWebApp'
96+
'Set-AzureRmWebApp', 'Start-AzureRmWebApp', 'Stop-AzureRmWebApp',
97+
'Get-AzureRmWebAppSnapshot', 'Restore-AzureRmWebAppSnapshot'
9798

9899
# Variables to export from this module
99100
# VariablesToExport = @()

src/ResourceManager/Websites/AzureRM.Websites.psd1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# RootModule = ''
1313

1414
# Version number of this module.
15-
ModuleVersion = '4.0.0'
15+
ModuleVersion = '5.0.0'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -93,7 +93,8 @@ CmdletsToExport = 'Get-AzureRmAppServicePlan', 'Set-AzureRmAppServicePlan',
9393
'New-AzureRmWebAppBackup', 'Remove-AzureRmWebApp',
9494
'New-AzureRmWebApp', 'Remove-AzureRmWebAppBackup',
9595
'Reset-AzureRmWebAppPublishingProfile', 'Restart-AzureRmWebApp',
96-
'Set-AzureRmWebApp', 'Start-AzureRmWebApp', 'Stop-AzureRmWebApp'
96+
'Set-AzureRmWebApp', 'Start-AzureRmWebApp', 'Stop-AzureRmWebApp',
97+
'Get-AzureRmWebAppSnapshot', 'Restore-AzureRmWebAppSnapshot'
9798

9899
# Variables to export from this module
99100
# VariablesToExport = @()
@@ -134,6 +135,8 @@ PrivateData = @{
134135
# External dependent modules of this module
135136
# ExternalModuleDependencies = ''
136137

138+
Prerelease = 'preview'
139+
137140
} # End of PSData hashtable
138141

139142
} # End of PrivateData hashtable

src/ResourceManager/Websites/Commands.Websites.Test/Commands.Websites.Test.csproj

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@
5959
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.3.0.0\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
6060
<Private>True</Private>
6161
</Reference>
62-
<Reference Include="Microsoft.Azure.Management.Websites, Version=1.0.0.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
63-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Websites.1.2.0-preview\lib\net45\Microsoft.Azure.Management.Websites.dll</HintPath>
64-
<Private>True</Private>
62+
<Reference Include="Microsoft.Azure.Management.Websites, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
63+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Websites.1.7.1-preview\lib\net452\Microsoft.Azure.Management.Websites.dll</HintPath>
6564
</Reference>
6665
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6766
<SpecificVersion>False</SpecificVersion>
@@ -85,12 +84,10 @@
8584
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
8685
</Reference>
8786
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
88-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.5\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
89-
<Private>True</Private>
87+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.10\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
9088
</Reference>
9189
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
92-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.5\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
93-
<Private>True</Private>
90+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.10\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
9491
</Reference>
9592
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework">
9693
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.5.0-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
@@ -226,6 +223,12 @@
226223
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests\TestGetWebAppBackupList.json">
227224
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
228225
</None>
226+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests\TestGetWebAppSnapshots.json">
227+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
228+
</None>
229+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests\TestRestoreWebAppSnapshot.json">
230+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
231+
</None>
229232
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppSlotTests\TestCloneWebAppSlot.json">
230233
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
231234
</None>

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/AppServicePlanTests.ps1

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,31 +333,28 @@ function Test-CreateNewAppServicePlanInAse
333333
$whpName = Get-WebHostPlanName
334334
$location = "West US"
335335
$capacity = 1
336-
$skuName = "S2"
337-
$aseName = "asedemo"
338-
$aseResourceGroupName = "appdemorg"
336+
$skuName = "I1"
337+
$aseName = "asedemops2"
338+
$aseResourceGroupName = "asedemorg"
339339

340340
try
341341
{
342342
#Setup
343343
New-AzureRmResourceGroup -Name $rgname -Location $location
344344

345345
# Test
346-
$createResult = New-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $location -Tier "Standard" -WorkerSize Medium -NumberOfWorkers $capacity -AseName $aseName -AseResourceGroupName $aseResourceGroupName
346+
$createResult = New-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $location -Tier "Isolated" -WorkerSize Medium -NumberOfWorkers $capacity -AseName $aseName -AseResourceGroupName $aseResourceGroupName
347347

348348
# Assert
349349
Assert-AreEqual $whpName $createResult.Name
350-
Assert-AreEqual "Standard" $createResult.Sku.Tier
350+
Assert-AreEqual "Isolated" $createResult.Sku.Tier
351351
Assert-AreEqual $skuName $createResult.Sku.Name
352-
Assert-AreEqual $capacity $createResult.Sku.Capacity
353352

354353
# Assert
355-
356354
$getResult = Get-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $whpName
357355
Assert-AreEqual $whpName $getResult.Name
358-
Assert-AreEqual "Standard" $getResult.Sku.Tier
356+
Assert-AreEqual "Isolated" $getResult.Sku.Tier
359357
Assert-AreEqual $skuName $getResult.Sku.Name
360-
Assert-AreEqual $capacity $getResult.Sku.Capacity
361358
}
362359
finally
363360
{

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/Common.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ function Get-SecondaryLocation
123123

124124
if ($location -eq $null)
125125
{
126-
return "East US"
126+
return "West US"
127127
} else
128128
{
129129
return $location.Locations[1]
130130
}
131131
}
132132

133-
return "EastUS"
133+
return "WestUS"
134134
}
135135

136136
<#

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/SSLBindingTests.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ assign a custom domain to it and update global variable values.
1717
#>
1818

1919
#Global variables
20-
$rgname = "webappsslbindingrb"
21-
$appname = "webappsslbindingtest"
20+
$rgname = "lketmtestantps10"
21+
$appname = "lketmtestantps10"
2222
$slot = "testslot"
23-
$prodHostname = "www.webappsslbindingtests.com"
24-
$slotHostname = "testslot.webappsslbindingtests.com"
25-
$thumbprint = "40D6600B0B8740C41BA4B3D13B967DDEF6ED1918"
23+
$prodHostname = "www.adorenow.net"
24+
$slotHostname = "testslot.adorenow.net"
25+
$thumbprint = "ECC61863C674D5CEE90AB06373D37342368F0413"
2626

2727
<#
2828
.SYNOPSIS
@@ -62,7 +62,7 @@ function Test-GetNewWebAppSSLBinding
6262

6363
# Test - Get commands for web app
6464
$getResult = Get-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname
65-
Assert-AreEqual 2 $getResult.Count
65+
Assert-AreEqual 1 $getResult.Count
6666
$currentHostNames = $getResult | Select -expand Name
6767
Assert-True { $currentHostNames -contains $createWebAppResult.Name }
6868
$getResult = Get-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Name $prodHostname
@@ -138,7 +138,7 @@ function Test-WebAppSSLBindingPipeSupport
138138

139139
# Test - Retrieve Ssl bindings using web app and web app slot objects
140140
$getResult = $webapp | Get-AzureRMWebAppSSLBinding
141-
Assert-AreEqual 2 $getResult.Count
141+
Assert-AreEqual 1 $getResult.Count
142142

143143
$getResult = $webappslot | Get-AzureRMWebAppSSLBinding
144144
Assert-AreEqual 1 $getResult.Count

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,17 @@ public void TestEditAndGetWebAppBackupConfigurationPiping()
6868
{
6969
WebsitesController.NewInstance.RunPsTest("Test-EditAndGetWebAppBackupConfigurationPiping");
7070
}
71+
72+
[Trait(Category.AcceptanceType, Category.CheckIn)]
73+
public void TestGetWebAppSnapshots()
74+
{
75+
WebsitesController.NewInstance.RunPsTest("Test-GetWebAppSnapshots");
76+
}
77+
78+
[Trait(Category.AcceptanceType, Category.CheckIn)]
79+
public void TestRestoreWebAppSnapshot()
80+
{
81+
WebsitesController.NewInstance.RunPsTest("Test-RestoreWebAppSnapshot");
82+
}
7183
}
7284
}

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

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
# Snapshots require a Premium app to exist for several hours.
16+
# Deploy a Premium app and update these global variables to re-record the snapshots tests.
17+
$snapshotRgName = 'onesdksnapshots'
18+
$snapshotAppName = 'onesdkpremapp'
19+
$snapshotAppSlot = 'staging'
20+
1521
function Test-CreateNewWebAppBackup
1622
{
1723
$rgName = Get-ResourceGroupName
@@ -314,6 +320,56 @@ function Test-EditAndGetWebAppBackupConfigurationPiping
314320
}
315321
}
316322

323+
function Test-GetWebAppSnapshots
324+
{
325+
# Test named parameters
326+
$snapshots = Get-AzureRmWebAppSnapshot -ResourceGroupName $snapshotRgName -Name $snapshotAppName
327+
Assert-True { $snapshots.Length -gt 0 }
328+
Assert-NotNull $snapshots[0]
329+
Assert-NotNull $snapshots[0].SnapshotTime
330+
Assert-AreEqual 'Production' $snapshots[0].Slot
331+
332+
# Test positional parameters
333+
$snapshots = Get-AzureRmWebAppSnapshot $snapshotRgName $snapshotAppName
334+
Assert-True { $snapshots.Length -gt 0 }
335+
Assert-NotNull $snapshots[0]
336+
Assert-NotNull $snapshots[0].SnapshotTime
337+
Assert-AreEqual 'Production' $snapshots[0].Slot
338+
339+
# Test snapshots for slots
340+
$snapshots = Get-AzureRmWebAppSnapshot -ResourceGroupName $snapshotRgName -Name $snapshotAppName -Slot $snapshotAppSlot
341+
Assert-True { $snapshots.Length -gt 0 }
342+
Assert-NotNull $snapshots[0]
343+
Assert-NotNull $snapshots[0].SnapshotTime
344+
Assert-AreEqual $snapshotAppSlot $snapshots[0].Slot
345+
346+
# Test piping
347+
$app = Get-AzureRmWebApp -ResourceGroupName $snapshotRgName -Name $snapshotAppName
348+
$snapshots = $app | Get-AzureRmWebAppSnapshot
349+
Assert-True { $snapshots.Length -gt 0 }
350+
Assert-NotNull $snapshots[0]
351+
Assert-NotNull $snapshots[0].SnapshotTime
352+
Assert-AreEqual 'Production' $snapshots[0].Slot
353+
}
354+
355+
function Test-RestoreWebAppSnapshot
356+
{
357+
# Test overwrite
358+
$snapshot = (Get-AzureRmWebAppSnapshot $snapshotRgName $snapshotAppName)[0]
359+
Restore-AzureRmWebAppSnapshot -ResourceGroupName $snapshotRgName -Name $snapshotAppName -SnapshotTime $snapshot.SnapshotTime -Force -RecoverConfiguration
360+
361+
# Test restore to target slot
362+
$target = Get-AzureRmWebAppSlot -ResourceGroupName $snapshotRgName -Name $snapshotAppName -Slot $snapshotAppSlot
363+
Restore-AzureRmWebAppSnapshot -ResourceGroupName $snapshotRgName -Name $snapshotAppName -SnapshotTime $snapshot.SnapshotTime -RecoverConfiguration -TargetApp $target
364+
365+
# Test piping
366+
$snapshot | Restore-AzureRmWebAppSnapshot -Force
367+
368+
# Test background job
369+
$snapshot | Restore-AzureRmWebAppSnapshot -Force -AsJob
370+
$job | Wait-Job
371+
}
372+
317373
# Utility functions
318374

319375
# Creates a new web app
@@ -346,7 +402,10 @@ function Create-TestStorageAccount
346402
$stoKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroup -Name $storageName).Key1;
347403
# 2 hour access duration
348404
$accessDuration = New-Object -TypeName TimeSpan(2,0,0)
349-
$permissions = [Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions]::Write
405+
$permissions = [Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions]::Write -bor
406+
[Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions]::Read -bor
407+
[Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions]::List -bor
408+
[Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions]::Delete
350409
$sasUri = Get-SasUri $storageName $stoKey $stoContainerName $accessDuration $permissions
351410
return $sasUri
352-
}
411+
}

0 commit comments

Comments
 (0)