Skip to content

Commit d212daa

Browse files
authored
Merge pull request #11 from Azure/dev
Merge from Azure
2 parents a716374 + 7a22019 commit d212daa

File tree

56 files changed

+70265
-118136
lines changed

Some content is hidden

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

56 files changed

+70265
-118136
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ This checklist is used to make sure that common guidelines for a pull request ar
2626

2727
### [Cmdlet Signature Guidelines](https://github.com/Azure/azure-powershell/blob/dev/CONTRIBUTING.md#cmdlet-signature-guidelines)
2828
- [ ] New cmdlets that make changes or have side effects should implement `ShouldProcess` and have `SupportShouldProcess=true` specified in the cmdlet attribute. You can find more information on `ShouldProcess` [here](https://gist.github.com/markcowl/338e16fe5c8bbf195aff9f8af0db585d#what-is-the-change).
29-
- [ ] Cmdlet specifies `OutputType` attribute if any output is produced - if the cmdlet produces no output, it should implement a `PassThrough` parameter.
29+
- [ ] Cmdlet specifies `OutputType` attribute if any output is produced - if the cmdlet produces no output, it should implement a `PassThru` parameter.
3030

3131
### [Cmdlet Parameter Guidelines](https://github.com/Azure/azure-powershell/blob/dev/CONTRIBUTING.md#cmdlet-parameter-guidelines)
3232
- [ ] Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
3333
- [ ] Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
34-
- [ ] Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.
34+
- [ ] Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ This repository contains a set of PowerShell cmdlets for developers and administ
3636
* Scheduler
3737
* StorSimple
3838
* Redis Cache
39-
39+
4040
* Windows Azure Pack
4141
* Web Site: CRUD web site, deployment, configure and get log, start/stop/restart/show web site
4242
* Service Bus: CRD namespace
@@ -46,7 +46,7 @@ This repository contains a set of PowerShell cmdlets for developers and administ
4646
* Windows Azure Stack
4747
* Azure Stack Administration
4848
* Storage Service Management
49-
49+
5050

5151
For detail descriptions and examples of the cmdlets, type
5252
* ```help azure``` to get all the cmdlets.
@@ -92,7 +92,7 @@ You can also find the standalone installers for all the versions at [Downloads](
9292

9393
In general, follow these steps to start using Microsoft Azure PowerShell
9494

95-
* Get yourself authenticated with Microsoft Azure. For details, please check out [this article](https://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/).
95+
* Get yourself authenticated with Microsoft Azure. For details, please check out [this article](https://docs.microsoft.com/powershell/azureps-cmdlets-docs/).
9696
* Option 1: Login with your Microsoft account or Organizational account directly from PowerShell. Microsoft Azure Active Directory authentication is used in this case. No management certificate is needed.
9797
* Starting from 1.0.0, you can use ```Add-AzureRmAccount -Credential``` to avoid the browser pop up for Organizational account.
9898
* To use RDFE cmdlets, use ```Add-AzureAccount```

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/Common/PSSiteRecoveryClient.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,12 @@ public CustomRequestHeaders GetRequestHeaders(bool shouldSignRequest = true)
312312
/// <returns>Site Recovery Management client</returns>
313313
private SiteRecoveryManagementClient GetSiteRecoveryClient()
314314
{
315+
if (string.IsNullOrEmpty(asrVaultCreds.ResourceName) ||
316+
string.IsNullOrEmpty(asrVaultCreds.ResourceGroupName))
317+
{
318+
throw new InvalidOperationException(Properties.Resources.MissingVaultSettings);
319+
}
320+
315321
SiteRecoveryManagementClient siteRecoveryClient =
316322
AzureSession.ClientFactory.CreateCustomClient<SiteRecoveryManagementClient>(
317323
asrVaultCreds.ResourceName,
@@ -426,4 +432,4 @@ public static T Deserialize(string xmlString)
426432
return propertyBagContainer;
427433
}
428434
}
429-
}
435+
}

src/ResourceManager/Sql/Commands.Sql.Test/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<package id="Microsoft.Rest.ClientRuntime" version="2.3.4" targetFramework="net45" />
2424
<package id="Microsoft.Rest.ClientRuntime.Azure" version="3.3.4" targetFramework="net45" />
2525
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.2.9-preview" targetFramework="net45" />
26+
<package id="Microsoft.Rest.ClientRuntime.Azure.TestFramework" version="1.5.0-preview" targetFramework="net45" />
2627
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
2728
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.1.1" targetFramework="net45" />
2829
<package id="Moq" version="4.2.1510.2205" targetFramework="net45" />

src/ResourceManager/Sql/Sql.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio 2013
2+
# Visual Studio 2015
33
VisualStudioVersion = 12.0.31101.0
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{95C16AED-FD57-42A0-86C3-2CF4300A4817}"

src/ServiceManagement/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@
226226
<None Include="Resources\DiagnosticsExtension\Files\diagnostics.wadcfgx">
227227
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
228228
</None>
229+
<None Include="Resources\SqlIaaSExtension\SqlIaaSExtensionTests.ps1">
230+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
231+
</None>
229232
<None Include="Resources\DscExtension\DscExtensionTests.ps1">
230233
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
231234
</None>
@@ -361,6 +364,9 @@
361364
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\TestNewAzureVMWithBYOL.json">
362365
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
363366
</None>
367+
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.SqlIaaSExtensionTests\TestGetAzureVMSqlIaaSExtension.json">
368+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
369+
</None>
364370
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.TrafficManagerTests\TestAddAzureTrafficManagerEndpoint.json">
365371
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
366372
</None>
@@ -432,6 +438,7 @@
432438
<Compile Include="CredentialTests\CredentialTestHelper.cs" />
433439
<Compile Include="ChefExtension\ChefExtensionTests.cs" />
434440
<Compile Include="DiagnosticsExtension\DiagnosticsExtensionTests.cs" />
441+
<Compile Include="SqlIaaSExtensionTests\SqlIaaSExtensionTests.cs" />
435442
<Compile Include="DscExtension\DscExtensionTests.cs" />
436443
<Compile Include="MediaServicesTests\MediaServicesTests.cs" />
437444
<Compile Include="Properties\Resources.Designer.cs">
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
$PLACEHOLDER = "PLACEHOLDER1@";
2+
3+
<#
4+
.SYNOPSIS
5+
End to end Sql IaaS extension test that tests Get-AzureVMSqlServerExtension cmdlet. It does the following:
6+
1) Creates cloud service and a VM with SQL 2016 Image.
7+
2) Installs the extension by calling Set-AzureVMSqlServerExtension cmdlet on the VM.
8+
3) Calls Get-AzureVMSqlServerExtension cmdlet to check the status of the extension installation.
9+
4) Sets Auto Patching and Auto Backup settings by calling Set-AzureVMDscExtension cmdlet on the VM.
10+
5) Calls Get-AzureVMSqlServerExtension cmdlet to get extension details and verify it with values updated with Set-AzureVMSqlServerExtension.
11+
#>
12+
function Test-GetAzureVMSqlIaaSExtension
13+
{
14+
Set-StrictMode -Version latest; $ErrorActionPreference = 'Stop'
15+
16+
# Setup
17+
$location = Get-DefaultLocation
18+
$storageName = getAssetName
19+
20+
try
21+
{
22+
New-AzureStorageAccount -StorageAccountName $storageName -Location $location
23+
Set-CurrentStorageAccountName $storageName
24+
25+
$vmName = "pshelltestvm1"
26+
$svcName = Get-CloudServiceName
27+
28+
# Get latest SQL 2016 VM Image
29+
$family = "SQL Server 2016 RTM Enterprise on Windows Server 2012 R2"
30+
$image = Get-AzureVMImage | where { $_.ImageFamily -eq $family } | sort PublishedDate -Descending | select -ExpandProperty ImageName -First 1
31+
32+
# Create new cloud service
33+
New-AzureService -ServiceName $svcName -Location $location
34+
35+
# Create the VM config
36+
$vmsize = "A5"
37+
$vm1 = New-AzureVMConfig -Name $vmname -InstanceSize $vmsize -ImageName $image
38+
39+
# Create the SQL VM
40+
$user = "localadmin";
41+
$password = $PLACEHOLDER;
42+
$vm1 | Add-AzureProvisioningConfig -Windows -AdminUsername $user -Password $password
43+
New-AzureVM –ServiceName $svcname -VMs $vm1
44+
45+
#Do actual changes and work here
46+
47+
# 1) Installs the SqlIaaS extension by calling Set-AzureVMSqlServerExtension cmdlet on a VM.
48+
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName
49+
$vm | Set-AzureVMSqlServerExtension | Update-AzureVM
50+
51+
# 2) Calls Get-AzureRmVMSqlServerExtension cmdlet to verify the status of the extension installation.
52+
$extension = $vm | Get-AzureVMSqlServerExtension
53+
Assert-NotNull $extension
54+
Assert-NotNull $extension.ExtensionName
55+
Assert-NotNull $extension.Publisher
56+
Assert-NotNull $extension.Version
57+
58+
# Repeat until the extension is ready.
59+
[TimeSpan] $timeout = [TimeSpan]::FromMinutes(30)
60+
$maxTime = [datetime]::Now + $timeout
61+
62+
while($true)
63+
{
64+
if($extension -ne $null -and $extension.ExtensionStatus -ne $null)
65+
{
66+
if(($extension.ExtensionStatus -eq "Ready"))
67+
{
68+
break;
69+
}
70+
}
71+
72+
if([datetime]::Now -gt $maxTime)
73+
{
74+
Throw "The Sql Server Extension did not report any status within the given timeout from VM [$vmName]"
75+
}
76+
77+
if ($env:AZURE_TEST_MODE -eq "Record"){
78+
sleep -Seconds 15
79+
}
80+
81+
$extension = $vm | Get-AzureVMSqlServerExtension
82+
}
83+
84+
# 3) Update Auto Patching and Auto Backup settings
85+
$storageContext = (Get-AzureStorageAccount -StorageAccountName $storageName).Context
86+
$aps = New-AzureVMSqlServerAutoPatchingConfig -Enable -DayOfWeek "Thursday" -MaintenanceWindowStartingHour 20 `
87+
-MaintenanceWindowDuration 120 -PatchCategory "Important"
88+
$abs = New-AzureVMSqlServerAutoBackupConfig -Enable -RetentionPeriodInDays 20 -StorageContext $storageContext -BackupScheduleType Manual `
89+
-BackupSystemDbs -FullBackupStartHour 10 -FullBackupWindowInHours 5 -FullBackupFrequency Daily -LogBackupFrequencyInMinutes 30
90+
Get-AzureVM -ServiceName $svcName -Name $vmName | Set-AzureVMSqlServerExtension -AutoPatchingSettings $aps -AutoBackupSettings $abs | Update-AzureVM
91+
92+
# Wait few minutes for the settings to be applied and to cover the lag for guest agent to pick up updated status.
93+
if ($env:AZURE_TEST_MODE -eq "Record"){
94+
sleep -Seconds 300
95+
}
96+
97+
# 4) Get the extension and verify the values.
98+
$extension = Get-AzureVM -ServiceName $svcName -Name $vmName | Get-AzureVMSqlServerExtension
99+
100+
Assert-AreEqual $extension.AutoPatchingSettings.DayOfWeek "Thursday"
101+
Assert-AreEqual $extension.AutoPatchingSettings.MaintenanceWindowStartingHour 20
102+
Assert-AreEqual $extension.AutoPatchingSettings.MaintenanceWindowDuration 120
103+
Assert-AreEqual $extension.AutoPatchingSettings.PatchCategory "Important"
104+
105+
Assert-AreEqual $extension.AutoBackupSettings.RetentionPeriod 20
106+
Assert-AreEqual $extension.AutoBackupSettings.Enable $true
107+
Assert-AreEqual $extension.AutoBackupSettings.BackupScheduleType "Manual"
108+
Assert-AreEqual $extension.AutoBackupSettings.FullBackupFrequency "Daily"
109+
Assert-AreEqual $extension.AutoBackupSettings.BackupSystemDbs $true
110+
Assert-AreEqual $extension.AutoBackupSettings.FullBackupStartTime 10
111+
Assert-AreEqual $extension.AutoBackupSettings.FullBackupWindowHours 5
112+
Assert-AreEqual $extension.AutoBackupSettings.LogBackupFrequency 30
113+
114+
# Uninstall Extension
115+
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName | Set-AzureVMSqlServerExtension -Uninstall | Update-AzureVM
116+
}
117+
finally
118+
{
119+
# Cleanup
120+
Remove-AzureStorageAccount -StorageAccountName $storageName -ErrorAction SilentlyContinue
121+
Cleanup-CloudService $svcName
122+
}
123+
}

src/ServiceManagement/Common/Commands.ScenarioTest/SessionRecords/Microsoft.WindowsAzure.Commands.ScenarioTest.SqlIaaSExtensionTests/TestGetAzureVMSqlIaaSExtension.json

Lines changed: 15744 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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 System.Collections.Generic;
16+
using System.IO;
17+
using System.Linq;
18+
using Microsoft.Azure.Test;
19+
using Microsoft.WindowsAzure.Management;
20+
using Microsoft.WindowsAzure.Management.Compute;
21+
using Microsoft.WindowsAzure.Management.Network;
22+
using Microsoft.WindowsAzure.Management.Storage;
23+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
24+
using Xunit;
25+
using Microsoft.Azure.Commands.Common.Authentication;
26+
using Xunit.Abstractions;
27+
using Microsoft.WindowsAzure.ServiceManagemenet.Common.Models;
28+
29+
namespace Microsoft.WindowsAzure.Commands.ScenarioTest
30+
{
31+
public class SqlIaaSExtensionTests
32+
{
33+
private EnvironmentSetupHelper helper = new EnvironmentSetupHelper();
34+
35+
public SqlIaaSExtensionTests(ITestOutputHelper output)
36+
{
37+
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
38+
}
39+
40+
[Fact]
41+
[Trait(Category.AcceptanceType, Category.CheckIn)]
42+
[Trait(Category.AcceptanceType, Category.BVT)]
43+
public void TestGetAzureVMSqlIaaSExtension()
44+
{
45+
this.RunPowerShellTest("Test-GetAzureVMSqlIaaSExtension");
46+
}
47+
48+
protected void SetupManagementClients()
49+
{
50+
var rdfeTestFactory = new RDFETestEnvironmentFactory();
51+
var managementClient = TestBase.GetServiceClient<ManagementClient>(rdfeTestFactory);
52+
var computeClient = TestBase.GetServiceClient<ComputeManagementClient>(rdfeTestFactory);
53+
var networkClient = TestBase.GetServiceClient<NetworkManagementClient>(rdfeTestFactory);
54+
var storageClient = TestBase.GetServiceClient<StorageManagementClient>(rdfeTestFactory);
55+
56+
helper.SetupSomeOfManagementClients(
57+
managementClient,
58+
computeClient,
59+
networkClient,
60+
storageClient);
61+
}
62+
63+
protected void RunPowerShellTest(params string[] scripts)
64+
{
65+
using (UndoContext context = UndoContext.Current)
66+
{
67+
context.Start(TestUtilities.GetCallingClass(1), TestUtilities.GetCurrentMethodName(2));
68+
69+
SetupManagementClients();
70+
71+
var modules = new List<string>
72+
{
73+
"Resources\\SqlIaaSExtension\\SqlIaaSExtensionTests.ps1",
74+
"Resources\\ServiceManagement\\Common.ps1",
75+
".\\Assert.ps1",
76+
@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Compute\AzurePreview.psd1"
77+
};
78+
79+
helper.SetupEnvironment(AzureModule.AzureServiceManagement);
80+
helper.SetupModules(AzureModule.AzureServiceManagement, modules.ToArray());
81+
82+
83+
var scriptEnvPath = new List<string>();
84+
scriptEnvPath.Add(
85+
string.Format(
86+
"$env:PSModulePath=\"{0};$env:PSModulePath\"",
87+
@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Compute".AsAbsoluteLocation()));
88+
89+
helper.RunPowerShellTest(scriptEnvPath, scripts);
90+
}
91+
}
92+
}
93+
}

src/ServiceManagement/Compute/Commands.ServiceManagement/Commands.ServiceManagement.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@
177177
<Compile Include="Common\ConstantStringTypes.cs" />
178178
<Compile Include="Common\DiagnosticsHelper.cs" />
179179
<Compile Include="IaaS\Extensions\Diagnostics\WADPrivateConfigSchema.cs" />
180+
<Compile Include="IaaS\Extensions\SqlServer\AzureVMSqlServerConfiguration.cs" />
181+
<Compile Include="IaaS\Extensions\SqlServer\AzureVMSqlServerKeyVaultCredential.cs" />
180182
<Compile Include="IaaS\Extensions\SqlServer\AzureVMSqlServerPublicAutoBackupSettings.cs" />
181183
<Compile Include="IaaS\Extensions\SqlServer\AzureVMSqlServerPublicKeyVaultCredentialSettings.cs" />
182184
<Compile Include="IaaS\Extensions\SqlServer\AzureVMSqlServerPrivateKeyVaultCredentialSettings.cs" />

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/SqlServer/AzureVMSqlServerAutoBackupSettings.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,35 @@ public class AutoBackupSettings
5050
/// Password required for certification when encryption is enabled
5151
/// </summary>
5252
public string Password { get; set; }
53+
54+
/// <summary>
55+
/// Whether to include system databases in Backup
56+
/// </summary>
57+
public bool? BackupSystemDbs { get; set; }
58+
59+
/// <summary>
60+
/// Gets the Backup Schedule Type
61+
/// </summary>
62+
public string BackupScheduleType { get; set; }
63+
64+
/// <summary>
65+
/// Gets the Full Backup Frequency
66+
/// </summary>
67+
public string FullBackupFrequency { get; set; }
68+
69+
/// <summary>
70+
/// Gets the Full Backup Start Time
71+
/// </summary>
72+
public int? FullBackupStartTime { get; set; }
73+
74+
/// <summary>
75+
/// Gets the Full Backup Window Hours
76+
/// </summary>
77+
public int? FullBackupWindowHours { get; set; }
78+
79+
/// <summary>
80+
/// Gets the Log Backup Frequency
81+
/// </summary>
82+
public int? LogBackupFrequency { get; set; }
5383
}
5484
}

0 commit comments

Comments
 (0)