Skip to content
Merged

rebase #12577

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 28 additions & 0 deletions .azure-pipelines/daily-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Please don't use ADO UI defined scheduled triggers because it takes precedence over YAML scheduled triggers.
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/scheduled-triggers
schedules:
- cron: "0 0 * * *"
displayName: Daily Midnight Build
branches:
include:
- master

pr: none

pool:
vmImage: 'windows-2019'

steps:
- task: DotNetCoreCLI@2
displayName: Build for Version Bump
inputs:
command: 'custom'
custom: 'msbuild'
arguments: 'build.proj'

- task: ComponentGovernanceComponentDetection@0
displayName: Component Detection
inputs:
scanType: 'Register'
verbosity: 'Normal'
alertWarningLevel: 'High'
2 changes: 1 addition & 1 deletion .azure-pipelines/powershell-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
displayName: Test
dependsOn: Build
condition: succeeded()
timeoutInMinutes: 120
timeoutInMinutes: 180
strategy:
matrix:
windows:
Expand Down
12 changes: 12 additions & 0 deletions .azure-pipelines/util/test-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ steps:
parameters:
osName: ${{ parameters.osName }}

- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 2.1.x

- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 3.1.x

- task: DotNetCoreCLI@2
displayName: Test
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,12 @@ public void TestVirtualMachineScaleSetImageVersion()
{
TestRunner.RunTestScript("Test-VirtualMachineScaleSetImageVersion");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineScaleSetNewEncryptionAtHost()
{
TestRunner.RunTestScript("Test-VirtualMachineScaleSetEncryptionAtHost");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2467,3 +2467,72 @@ function Test-VirtualMachineScaleSetImageVersion
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
testing encryptionAtHost cmdlet for
new-azvmss - create vmss using simple parameter set and hostencryption tag.
update-azvmss test boolean parameter
new-azvmssconfig
#>
function Test-VirtualMachineScaleSetEncryptionAtHost
{
# Setup
$rgname = Get-ComputeTestResourceName

try
{
# Common
$loc = Get-Location "Microsoft.Compute" "virtualMachines";
New-AzResourceGroup -Name $rgname -Location $loc -Force;

# SRP
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$stoaccount = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname;

# NRP
$subnet = New-AzVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;

# New VMSS Parameters
$vmssName = 'vmsswithconfig';
$adminUsername = 'Foo12';
$adminPassword = $PLACEHOLDER;

$securePassword = ConvertTo-SecureString $adminPassword -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($adminUsername, $securePassword);


$imgRef = Get-DefaultCRPImage -loc $loc;
$ipCfg = New-AzVmssIPConfig -Name 'test' -SubnetId $subnetId;

$vmss = New-AzVmssConfig -Location $loc -SkuCapacity 2 -SkuName 'Standard_E4-2ds_v4' -UpgradePolicyMode 'Manual' -EncryptionAtHost `
| Add-AzVmssNetworkInterfaceConfiguration -Name 'test' -Primary $true -IPConfiguration $ipCfg `
| Set-AzVmssOSProfile -ComputerNamePrefix 'test' -AdminUsername $adminUsername -AdminPassword $adminPassword `
| Set-AzVmssStorageProfile -OsDiskCreateOption 'FromImage' -OsDiskCaching 'None' `
-ImageReferenceOffer $imgRef.Offer -ImageReferenceSku $imgRef.Skus -ImageReferenceVersion 'latest' `
-ImageReferencePublisher $imgRef.PublisherName ;

#creating vmss using new-azvmss default parameter set which uses New-VmssConfig with -EncryptionAtHost parameter
$vmssResult1 = New-AzVmss -ResourceGroupName $rgname -Name $vmssName -VirtualMachineScaleSet $vmss
#creating vmss using New-azvmss simple parameter set
$vmssResult2 = New-AzVmss -ResourceGroupName $rgname -VMScaleSetName "newvmss" -Credential $cred -EncryptionAtHost -DomainNameLabel "domainlabel"

Assert-AreEqual $vmssResult1.VirtualMachineProfile.SecurityProfile.EncryptionAtHost True;
Assert-AreEqual $vmssResult2.VirtualMachineProfile.SecurityProfile.EncryptionAtHost True;

#using Update-azvmss to turn off encryptionAtHost
$updatedVM = Update-azvmss -ResourceGroupName $rgname -VMScaleSetName $vmssName -VirtualMachineScaleSet $vmssResult1 -EncryptionAtHost $false

Assert-False { $updatedVM.VirtualMachineProfile.SecurityProfile.EncryptionAtHost };
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
14 changes: 14 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,20 @@ public void TestLowPriorityVirtualMachine()
TestRunner.RunTestScript("Test-LowPriorityVirtualMachine");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestEncryptionAtHostVM()
{
TestRunner.RunTestScript("Test-EncryptionAtHostVM");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestEncryptionAtHostVMDefaultParameterSet()
{
TestRunner.RunTestScript("Test-EncryptionAtHostVMDefaultParamSet");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetAzVMOperatingSystem()
Expand Down
156 changes: 156 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3854,6 +3854,162 @@ function Test-LowPriorityVirtualMachine
}
}

<#
.SYNOPSIS
Test EncryptionAtHost Virtual Machine
#>
function Test-EncryptionAtHostVM
{
# Setup
$rgname = Get-ComputeTestResourceName

try
{
$loc = Get-ComputeVMLocation;
New-AzResourceGroup -Name $rgname -Location $loc -Force;

# VM Profile & Hardware

$vmsize = 'Standard_DS2_v2';
$vmname = 'vm' + $rgname;
[string]$domainNameLabel = "$vmname-$vmname".tolower();

$user = "Foo2";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';

New-AzVM -ResourceGroupName $rgname -Name $vmname -Credential $cred -DomainNameLabel $domainNameLabel -EncryptionAtHost;

# Get VM
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname;
Assert-AreEqual True $vm.SecurityProfile.encryptionAtHost
Assert-ThrowsContains { Update-AzVM -ResourceGroupName $rgname -VM $vm -EncryptionAtHost $false; } "can be updated only when VM is in deallocated state"

#update vm with encryptionathost false
Stop-AzVM -ResourceGroupName $rgname -Name $vmname -Force;
Update-AzVM -ResourceGroupName $rgname -VM $vm -EncryptionAtHost $false;
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname;
Assert-AreEqual False $vm.SecurityProfile.encryptionAtHost

#update vm with encryptionathost false
Update-AzVM -ResourceGroupName $rgname -VM $vm -EncryptionAtHost $true;
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname;
Assert-AreEqual True $vm.SecurityProfile.encryptionAtHost
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
<#
.SYNOPSIS
Test EncryptionAtHost Virtual Machine Default Param Set
#>
function Test-EncryptionAtHostVMDefaultParamSet
{
# Setup
$rgname = Get-ComputeTestResourceName

try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzResourceGroup -Name $rgname -Location $loc -Force;

# VM Profile & Hardware
$vmsize = 'Standard_DS2_v2';
$vmname = 'vm' + $rgname;
$p = New-AzVMConfig -VMName $vmname -VMSize $vmsize -EncryptionAtHost;

# NRP
$subnet = New-AzVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;

$p = Add-AzVMNetworkInterface -VM $p -Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;

# Storage Account (SA)
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$stoaccount = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname;

$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
$dataDiskVhdUri3 = "https://$stoname.blob.core.windows.net/test/data3.vhd";

$p = Set-AzVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;

$p = Add-AzVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
$p = Add-AzVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 2 -VhdUri $dataDiskVhdUri2 -CreateOption Empty;
$p = Add-AzVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB 12 -Lun 3 -VhdUri $dataDiskVhdUri3 -CreateOption Empty;
$p = Remove-AzVMDataDisk -VM $p -Name 'testDataDisk3';

Assert-AreEqual $p.StorageProfile.OSDisk.Caching $osDiskCaching;
Assert-AreEqual $p.StorageProfile.OSDisk.Name $osDiskName;
Assert-AreEqual $p.StorageProfile.OSDisk.Vhd.Uri $osDiskVhdUri;
Assert-AreEqual $p.StorageProfile.DataDisks.Count 2;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[0].DiskSizeGB 10;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Lun 1;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Vhd.Uri $dataDiskVhdUri1;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[1].DiskSizeGB 11;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Lun 2;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Vhd.Uri $dataDiskVhdUri2;

# OS & Image
$user = "Foo12";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
$img = 'a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-Datacenter-201503.01-en.us-127GB.vhd';

# $p.StorageProfile.OSDisk = $null;
$p = Set-AzVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;

Assert-AreEqual $p.OSProfile.AdminUsername $user;
Assert-AreEqual $p.OSProfile.ComputerName $computerName;
Assert-AreEqual $p.OSProfile.AdminPassword $password;

# Image Reference
$imgRef = Get-DefaultCRPImage -loc $loc;
$p = ($imgRef | Set-AzVMSourceImage -VM $p);

$p.StorageProfile.DataDisks = $null;

# Virtual Machine
New-AzVM -ResourceGroupName $rgname -Location $loc -VM $p;
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname;
Assert-AreEqual True $vm.SecurityProfile.encryptionAtHost

# Remove
Remove-AzVM -ResourceGroupName $rgname -Name $vmname -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Test Set-AzVMOperatingSystem
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
- Additional information about change #1
-->
## Upcoming Release
* Added '-EncryptionAtHost' parameter to New-AzVm, New-AzVmss, New-AzVMConfig, New-AzVmssConfig, Update-AzVM, and Update-AzVmss
* Added 'SecurityProfile' to Get-AzVM and Get-AzVmss return object
* Added the '-InstanceView' switch as optional parameter to Get-AzHostGroup


## Version 4.2.1
* Added warning when using `New-AzVmss` without "latest" image version.
* Added `-Location` as optional positional parameter to `Get-AzComputeResourceSku` cmdlet.
* Added `-PatchMode` as optional parameter to `Set-AzVMOperatingSystem` cmdlet.
* Added warning when using `New-AzVmss` without "latest" image version
* Added '-Location' as optional positional parameter to Get-AzComputeResourceSku cmdlet

## Version 4.2.0
* Added SimulateEviction parameter to Set-AzVM and Set-AzVmssVM cmdlets.
Expand Down
2 changes: 1 addition & 1 deletion src/Compute/Compute/Compute.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PsModuleName>Compute</PsModuleName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public string ResourceGroupName
public string Type { get; set; }
public string Location { get; set; }
public IDictionary<string, string> Tags { get; set; }
public PSVirtualMachineScaleSetVMProfile VirtualMachineProfile { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ public partial class NewAzureRmVmssConfigCommand : Microsoft.Azure.Commands.Reso
ValueFromPipelineByPropertyName = true)]
public string[] IdentityId { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true)]
public SwitchParameter EncryptionAtHost { get; set; }

protected override void ProcessRecord()
{
if (ShouldProcess("VirtualMachineScaleSet", "New"))
Expand Down Expand Up @@ -378,6 +383,19 @@ private void Run()
vAutomaticRepairsPolicy.Enabled = this.EnableAutomaticRepair.IsPresent;
}

if (this.EncryptionAtHost.IsPresent)
{
if (vVirtualMachineProfile == null)
{
vVirtualMachineProfile = new PSVirtualMachineScaleSetVMProfile();
}
if (vVirtualMachineProfile.SecurityProfile == null)
{
vVirtualMachineProfile.SecurityProfile = new SecurityProfile();
}
vVirtualMachineProfile.SecurityProfile.EncryptionAtHost = this.EncryptionAtHost;
}

if (this.IsParameterBound(c => c.AutomaticRepairGracePeriod))
{
if (vAutomaticRepairsPolicy == null)
Expand Down
Loading