Skip to content

Commit b32ee4f

Browse files
author
Hovsep
committed
Merge pull request #2073 from Nking92/Release.1.3.2
[Release.1.3.2] Add backup and restore cmdlets for Azure Web Apps
2 parents 0b2d429 + 0a74380 commit b32ee4f

30 files changed

+10433
-15
lines changed

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@
6060
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6161
<Private>True</Private>
6262
</Reference>
63+
<Reference Include="Microsoft.Azure.Management.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
64+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.3.0.0\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
65+
<Private>True</Private>
66+
</Reference>
6367
<Reference Include="Microsoft.Azure.Management.Websites, Version=1.0.0.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
64-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Websites.1.1.0-preview\lib\net45\Microsoft.Azure.Management.Websites.dll</HintPath>
68+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Websites.1.2.0-preview\lib\net45\Microsoft.Azure.Management.Websites.dll</HintPath>
6569
<Private>True</Private>
6670
</Reference>
6771
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -140,6 +144,7 @@
140144
</ItemGroup>
141145
<ItemGroup>
142146
<Compile Include="ScenarioTests\AppServicePlanTests.cs" />
147+
<Compile Include="ScenarioTests\WebAppBackupRestoreTests.cs" />
143148
<Compile Include="ScenarioTests\SSLBindingTests.cs" />
144149
<Compile Include="ScenarioTests\WebAppSlotTests.cs" />
145150
<Compile Include="ScenarioTests\WebsitesController.cs" />
@@ -157,6 +162,9 @@
157162
<None Include="ScenarioTests\AppServicePlanTests.ps1">
158163
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
159164
</None>
165+
<None Include="ScenarioTests\WebAppBackupRestoreTests.ps1">
166+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
167+
</None>
160168
<None Include="ScenarioTests\SSLBindingTests.ps1">
161169
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
162170
</None>
@@ -199,6 +207,24 @@
199207
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.SSLBindingTests\TestWebAppSSLBindingPipeSupport.json">
200208
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
201209
</None>
210+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests\TestCreateNewWebAppBackup.json">
211+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
212+
</None>
213+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests\TestCreateNewWebAppBackupPiping.json">
214+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
215+
</None>
216+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests\TestEditAndGetWebAppBackupConfiguration.json">
217+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
218+
</None>
219+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests\TestEditAndGetWebAppBackupConfigurationPiping.json">
220+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
221+
</None>
222+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests\TestGetWebAppBackup.json">
223+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
224+
</None>
225+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests\TestGetWebAppBackupList.json">
226+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
227+
</None>
202228
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppSlotTests\TestCloneWebAppSlot.json">
203229
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
204230
</None>
@@ -278,6 +304,10 @@
278304
<Project>{e1f5201d-6067-430e-b303-4e367652991b}</Project>
279305
<Name>Commands.Resources</Name>
280306
</ProjectReference>
307+
<ProjectReference Include="..\..\Storage\Commands.Management.Storage\Commands.Management.Storage.csproj">
308+
<Project>{a50ab133-5c04-4a17-9054-f8343683ec23}</Project>
309+
<Name>Commands.Management.Storage</Name>
310+
</ProjectReference>
281311
<ProjectReference Include="..\Commands.Websites\Commands.Websites.csproj">
282312
<Project>{80a92297-7c92-456b-8ee7-9fb6ce30149d}</Project>
283313
<Name>Commands.Websites</Name>

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ function Get-ResourceGroupName
4848
return getAssetName
4949
}
5050

51+
<#
52+
.SYNOPSIS
53+
Gets a backup name for testing.
54+
#>
55+
function Get-BackupName
56+
{
57+
return getAssetName
58+
}
59+
5160
<#
5261
.SYNOPSIS
5362
Gets an aseName for testing.
@@ -133,4 +142,22 @@ function PingWebApp($webApp)
133142

134143
return $statusCode
135144
}
136-
}
145+
}
146+
147+
# Create a SAS Uri
148+
function Get-SasUri
149+
{
150+
param ([string] $storageAccount, [string] $storageKey, [string] $container, [TimeSpan] $duration, [Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions] $type)
151+
152+
$uri = "https://$storageAccount.blob.core.windows.net/$container"
153+
154+
$destUri = New-Object -TypeName System.Uri($uri);
155+
$cred = New-Object -TypeName Microsoft.WindowsAzure.Storage.Auth.StorageCredentials($storageAccount, $storageKey);
156+
$destBlob = New-Object -TypeName Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob($destUri, $cred);
157+
$policy = New-Object Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy;
158+
$policy.Permissions = $type;
159+
$policy.SharedAccessExpiryTime = (Get-Date).Add($duration);
160+
$uri += $destBlob.GetSharedAccessSignature($policy);
161+
162+
return $uri;
163+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
17+
using Xunit;
18+
19+
namespace Microsoft.Azure.Commands.Websites.Test.ScenarioTests
20+
{
21+
public class WebAppBackupRestoreTests : RMTestBase
22+
{
23+
[Fact]
24+
[Trait(Category.AcceptanceType, Category.CheckIn)]
25+
public void TestCreateNewWebAppBackup()
26+
{
27+
WebsitesController.NewInstance.RunPsTest("Test-CreateNewWebAppBackup");
28+
}
29+
30+
[Fact]
31+
[Trait(Category.AcceptanceType, Category.CheckIn)]
32+
public void TestCreateNewWebAppBackupPiping()
33+
{
34+
WebsitesController.NewInstance.RunPsTest("Test-CreateNewWebAppBackupPiping");
35+
}
36+
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.CheckIn)]
39+
public void TestGetWebAppBackup()
40+
{
41+
WebsitesController.NewInstance.RunPsTest("Test-GetWebAppBackup");
42+
}
43+
44+
[Fact]
45+
[Trait(Category.AcceptanceType, Category.CheckIn)]
46+
public void TestGetWebAppBackupList()
47+
{
48+
WebsitesController.NewInstance.RunPsTest("Test-GetWebAppBackupList");
49+
}
50+
51+
[Fact]
52+
[Trait(Category.AcceptanceType, Category.CheckIn)]
53+
public void TestEditAndGetWebAppBackupConfiguration()
54+
{
55+
WebsitesController.NewInstance.RunPsTest("Test-EditAndGetWebAppBackupConfiguration");
56+
}
57+
58+
[Fact]
59+
[Trait(Category.AcceptanceType, Category.CheckIn)]
60+
public void TestEditAndGetWebAppBackupConfigurationPiping()
61+
{
62+
WebsitesController.NewInstance.RunPsTest("Test-EditAndGetWebAppBackupConfigurationPiping");
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)