Skip to content

Commit

Permalink
Merge pull request #11 from Azure/dev
Browse files Browse the repository at this point in the history
Merge from Azure
  • Loading branch information
yaakoviyun authored Jan 7, 2017
2 parents a716374 + 7a22019 commit d212daa
Show file tree
Hide file tree
Showing 56 changed files with 70,265 additions and 118,136 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ This checklist is used to make sure that common guidelines for a pull request ar

### [Cmdlet Signature Guidelines](https://github.com/Azure/azure-powershell/blob/dev/CONTRIBUTING.md#cmdlet-signature-guidelines)
- [ ] 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).
- [ ] Cmdlet specifies `OutputType` attribute if any output is produced - if the cmdlet produces no output, it should implement a `PassThrough` parameter.
- [ ] Cmdlet specifies `OutputType` attribute if any output is produced - if the cmdlet produces no output, it should implement a `PassThru` parameter.

### [Cmdlet Parameter Guidelines](https://github.com/Azure/azure-powershell/blob/dev/CONTRIBUTING.md#cmdlet-parameter-guidelines)
- [ ] Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
- [ ] 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.
- [ ] Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.
- [ ] Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This repository contains a set of PowerShell cmdlets for developers and administ
* Scheduler
* StorSimple
* Redis Cache

* Windows Azure Pack
* Web Site: CRUD web site, deployment, configure and get log, start/stop/restart/show web site
* Service Bus: CRD namespace
Expand All @@ -46,7 +46,7 @@ This repository contains a set of PowerShell cmdlets for developers and administ
* Windows Azure Stack
* Azure Stack Administration
* Storage Service Management


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

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

* Get yourself authenticated with Microsoft Azure. For details, please check out [this article](https://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/).
* Get yourself authenticated with Microsoft Azure. For details, please check out [this article](https://docs.microsoft.com/powershell/azureps-cmdlets-docs/).
* 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.
* Starting from 1.0.0, you can use ```Add-AzureRmAccount -Credential``` to avoid the browser pop up for Organizational account.
* To use RDFE cmdlets, use ```Add-AzureAccount```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ public CustomRequestHeaders GetRequestHeaders(bool shouldSignRequest = true)
/// <returns>Site Recovery Management client</returns>
private SiteRecoveryManagementClient GetSiteRecoveryClient()
{
if (string.IsNullOrEmpty(asrVaultCreds.ResourceName) ||
string.IsNullOrEmpty(asrVaultCreds.ResourceGroupName))
{
throw new InvalidOperationException(Properties.Resources.MissingVaultSettings);
}

SiteRecoveryManagementClient siteRecoveryClient =
AzureSession.ClientFactory.CreateCustomClient<SiteRecoveryManagementClient>(
asrVaultCreds.ResourceName,
Expand Down Expand Up @@ -426,4 +432,4 @@ public static T Deserialize(string xmlString)
return propertyBagContainer;
}
}
}
}
1 change: 1 addition & 0 deletions src/ResourceManager/Sql/Commands.Sql.Test/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<package id="Microsoft.Rest.ClientRuntime" version="2.3.4" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime.Azure" version="3.3.4" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.2.9-preview" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime.Azure.TestFramework" version="1.5.0-preview" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.1.1" targetFramework="net45" />
<package id="Moq" version="4.2.1510.2205" targetFramework="net45" />
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/Sql/Sql.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
# Visual Studio 2015
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{95C16AED-FD57-42A0-86C3-2CF4300A4817}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@
<None Include="Resources\DiagnosticsExtension\Files\diagnostics.wadcfgx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\SqlIaaSExtension\SqlIaaSExtensionTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\DscExtension\DscExtensionTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -361,6 +364,9 @@
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\TestNewAzureVMWithBYOL.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.SqlIaaSExtensionTests\TestGetAzureVMSqlIaaSExtension.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.TrafficManagerTests\TestAddAzureTrafficManagerEndpoint.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -432,6 +438,7 @@
<Compile Include="CredentialTests\CredentialTestHelper.cs" />
<Compile Include="ChefExtension\ChefExtensionTests.cs" />
<Compile Include="DiagnosticsExtension\DiagnosticsExtensionTests.cs" />
<Compile Include="SqlIaaSExtensionTests\SqlIaaSExtensionTests.cs" />
<Compile Include="DscExtension\DscExtensionTests.cs" />
<Compile Include="MediaServicesTests\MediaServicesTests.cs" />
<Compile Include="Properties\Resources.Designer.cs">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
$PLACEHOLDER = "PLACEHOLDER1@";

<#
.SYNOPSIS
End to end Sql IaaS extension test that tests Get-AzureVMSqlServerExtension cmdlet. It does the following:
1) Creates cloud service and a VM with SQL 2016 Image.
2) Installs the extension by calling Set-AzureVMSqlServerExtension cmdlet on the VM.
3) Calls Get-AzureVMSqlServerExtension cmdlet to check the status of the extension installation.
4) Sets Auto Patching and Auto Backup settings by calling Set-AzureVMDscExtension cmdlet on the VM.
5) Calls Get-AzureVMSqlServerExtension cmdlet to get extension details and verify it with values updated with Set-AzureVMSqlServerExtension.
#>
function Test-GetAzureVMSqlIaaSExtension
{
Set-StrictMode -Version latest; $ErrorActionPreference = 'Stop'

# Setup
$location = Get-DefaultLocation
$storageName = getAssetName

try
{
New-AzureStorageAccount -StorageAccountName $storageName -Location $location
Set-CurrentStorageAccountName $storageName

$vmName = "pshelltestvm1"
$svcName = Get-CloudServiceName

# Get latest SQL 2016 VM Image
$family = "SQL Server 2016 RTM Enterprise on Windows Server 2012 R2"
$image = Get-AzureVMImage | where { $_.ImageFamily -eq $family } | sort PublishedDate -Descending | select -ExpandProperty ImageName -First 1

# Create new cloud service
New-AzureService -ServiceName $svcName -Location $location

# Create the VM config
$vmsize = "A5"
$vm1 = New-AzureVMConfig -Name $vmname -InstanceSize $vmsize -ImageName $image

# Create the SQL VM
$user = "localadmin";
$password = $PLACEHOLDER;
$vm1 | Add-AzureProvisioningConfig -Windows -AdminUsername $user -Password $password
New-AzureVM –ServiceName $svcname -VMs $vm1

#Do actual changes and work here

# 1) Installs the SqlIaaS extension by calling Set-AzureVMSqlServerExtension cmdlet on a VM.
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName
$vm | Set-AzureVMSqlServerExtension | Update-AzureVM

# 2) Calls Get-AzureRmVMSqlServerExtension cmdlet to verify the status of the extension installation.
$extension = $vm | Get-AzureVMSqlServerExtension
Assert-NotNull $extension
Assert-NotNull $extension.ExtensionName
Assert-NotNull $extension.Publisher
Assert-NotNull $extension.Version

# Repeat until the extension is ready.
[TimeSpan] $timeout = [TimeSpan]::FromMinutes(30)
$maxTime = [datetime]::Now + $timeout

while($true)
{
if($extension -ne $null -and $extension.ExtensionStatus -ne $null)
{
if(($extension.ExtensionStatus -eq "Ready"))
{
break;
}
}

if([datetime]::Now -gt $maxTime)
{
Throw "The Sql Server Extension did not report any status within the given timeout from VM [$vmName]"
}

if ($env:AZURE_TEST_MODE -eq "Record"){
sleep -Seconds 15
}

$extension = $vm | Get-AzureVMSqlServerExtension
}

# 3) Update Auto Patching and Auto Backup settings
$storageContext = (Get-AzureStorageAccount -StorageAccountName $storageName).Context
$aps = New-AzureVMSqlServerAutoPatchingConfig -Enable -DayOfWeek "Thursday" -MaintenanceWindowStartingHour 20 `
-MaintenanceWindowDuration 120 -PatchCategory "Important"
$abs = New-AzureVMSqlServerAutoBackupConfig -Enable -RetentionPeriodInDays 20 -StorageContext $storageContext -BackupScheduleType Manual `
-BackupSystemDbs -FullBackupStartHour 10 -FullBackupWindowInHours 5 -FullBackupFrequency Daily -LogBackupFrequencyInMinutes 30
Get-AzureVM -ServiceName $svcName -Name $vmName | Set-AzureVMSqlServerExtension -AutoPatchingSettings $aps -AutoBackupSettings $abs | Update-AzureVM

# Wait few minutes for the settings to be applied and to cover the lag for guest agent to pick up updated status.
if ($env:AZURE_TEST_MODE -eq "Record"){
sleep -Seconds 300
}

# 4) Get the extension and verify the values.
$extension = Get-AzureVM -ServiceName $svcName -Name $vmName | Get-AzureVMSqlServerExtension

Assert-AreEqual $extension.AutoPatchingSettings.DayOfWeek "Thursday"
Assert-AreEqual $extension.AutoPatchingSettings.MaintenanceWindowStartingHour 20
Assert-AreEqual $extension.AutoPatchingSettings.MaintenanceWindowDuration 120
Assert-AreEqual $extension.AutoPatchingSettings.PatchCategory "Important"

Assert-AreEqual $extension.AutoBackupSettings.RetentionPeriod 20
Assert-AreEqual $extension.AutoBackupSettings.Enable $true
Assert-AreEqual $extension.AutoBackupSettings.BackupScheduleType "Manual"
Assert-AreEqual $extension.AutoBackupSettings.FullBackupFrequency "Daily"
Assert-AreEqual $extension.AutoBackupSettings.BackupSystemDbs $true
Assert-AreEqual $extension.AutoBackupSettings.FullBackupStartTime 10
Assert-AreEqual $extension.AutoBackupSettings.FullBackupWindowHours 5
Assert-AreEqual $extension.AutoBackupSettings.LogBackupFrequency 30

# Uninstall Extension
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName | Set-AzureVMSqlServerExtension -Uninstall | Update-AzureVM
}
finally
{
# Cleanup
Remove-AzureStorageAccount -StorageAccountName $storageName -ErrorAction SilentlyContinue
Cleanup-CloudService $svcName
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Azure.Test;
using Microsoft.WindowsAzure.Management;
using Microsoft.WindowsAzure.Management.Compute;
using Microsoft.WindowsAzure.Management.Network;
using Microsoft.WindowsAzure.Management.Storage;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Xunit;
using Microsoft.Azure.Commands.Common.Authentication;
using Xunit.Abstractions;
using Microsoft.WindowsAzure.ServiceManagemenet.Common.Models;

namespace Microsoft.WindowsAzure.Commands.ScenarioTest
{
public class SqlIaaSExtensionTests
{
private EnvironmentSetupHelper helper = new EnvironmentSetupHelper();

public SqlIaaSExtensionTests(ITestOutputHelper output)
{
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.AcceptanceType, Category.BVT)]
public void TestGetAzureVMSqlIaaSExtension()
{
this.RunPowerShellTest("Test-GetAzureVMSqlIaaSExtension");
}

protected void SetupManagementClients()
{
var rdfeTestFactory = new RDFETestEnvironmentFactory();
var managementClient = TestBase.GetServiceClient<ManagementClient>(rdfeTestFactory);
var computeClient = TestBase.GetServiceClient<ComputeManagementClient>(rdfeTestFactory);
var networkClient = TestBase.GetServiceClient<NetworkManagementClient>(rdfeTestFactory);
var storageClient = TestBase.GetServiceClient<StorageManagementClient>(rdfeTestFactory);

helper.SetupSomeOfManagementClients(
managementClient,
computeClient,
networkClient,
storageClient);
}

protected void RunPowerShellTest(params string[] scripts)
{
using (UndoContext context = UndoContext.Current)
{
context.Start(TestUtilities.GetCallingClass(1), TestUtilities.GetCurrentMethodName(2));

SetupManagementClients();

var modules = new List<string>
{
"Resources\\SqlIaaSExtension\\SqlIaaSExtensionTests.ps1",
"Resources\\ServiceManagement\\Common.ps1",
".\\Assert.ps1",
@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Compute\AzurePreview.psd1"
};

helper.SetupEnvironment(AzureModule.AzureServiceManagement);
helper.SetupModules(AzureModule.AzureServiceManagement, modules.ToArray());


var scriptEnvPath = new List<string>();
scriptEnvPath.Add(
string.Format(
"$env:PSModulePath=\"{0};$env:PSModulePath\"",
@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Compute".AsAbsoluteLocation()));

helper.RunPowerShellTest(scriptEnvPath, scripts);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@
<Compile Include="Common\ConstantStringTypes.cs" />
<Compile Include="Common\DiagnosticsHelper.cs" />
<Compile Include="IaaS\Extensions\Diagnostics\WADPrivateConfigSchema.cs" />
<Compile Include="IaaS\Extensions\SqlServer\AzureVMSqlServerConfiguration.cs" />
<Compile Include="IaaS\Extensions\SqlServer\AzureVMSqlServerKeyVaultCredential.cs" />
<Compile Include="IaaS\Extensions\SqlServer\AzureVMSqlServerPublicAutoBackupSettings.cs" />
<Compile Include="IaaS\Extensions\SqlServer\AzureVMSqlServerPublicKeyVaultCredentialSettings.cs" />
<Compile Include="IaaS\Extensions\SqlServer\AzureVMSqlServerPrivateKeyVaultCredentialSettings.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,35 @@ public class AutoBackupSettings
/// Password required for certification when encryption is enabled
/// </summary>
public string Password { get; set; }

/// <summary>
/// Whether to include system databases in Backup
/// </summary>
public bool? BackupSystemDbs { get; set; }

/// <summary>
/// Gets the Backup Schedule Type
/// </summary>
public string BackupScheduleType { get; set; }

/// <summary>
/// Gets the Full Backup Frequency
/// </summary>
public string FullBackupFrequency { get; set; }

/// <summary>
/// Gets the Full Backup Start Time
/// </summary>
public int? FullBackupStartTime { get; set; }

/// <summary>
/// Gets the Full Backup Window Hours
/// </summary>
public int? FullBackupWindowHours { get; set; }

/// <summary>
/// Gets the Log Backup Frequency
/// </summary>
public int? LogBackupFrequency { get; set; }
}
}
Loading

0 comments on commit d212daa

Please sign in to comment.