Skip to content

Commit 075a1cc

Browse files
authored
New-AzPPG cmdlet add the Zone and IntentVMList parameters (#19331)
* Update PPGTests.cs * Update PPGTests.ps1 * Create TestPPGVMIntentListAndZones.json * Update ChangeLog.md * Update PSProximityPlacementGroup.cs * Update ProximityPlacementGroupCreateOrUpdateMethod.cs * Update ProximityPlacementGroupCreateOrUpdateMethod.cs * Update New-AzProximityPlacementGroup.md
1 parent 4b63340 commit 075a1cc

File tree

7 files changed

+3748
-2
lines changed

7 files changed

+3748
-2
lines changed

src/Compute/Compute.Test/ScenarioTests/PPGTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,12 @@ public void TestPPGVM()
4545
{
4646
TestRunner.RunTestScript("Test-ProximityPlacementGroupVM");
4747
}
48+
49+
[Fact]
50+
[Trait(Category.AcceptanceType, Category.CheckIn)]
51+
public void TestPPGVMIntentListAndZones()
52+
{
53+
TestRunner.RunTestScript("Test-PPGVMIntentAndZoneFeatures");
54+
}
4855
}
4956
}

src/Compute/Compute.Test/ScenarioTests/PPGTests.ps1

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,87 @@ function Test-ProximityPlacementGroupVM
337337
Clean-ResourceGroup $rgname
338338
}
339339
}
340+
341+
<#
342+
.SYNOPSIS
343+
Test the PPG Zones and the vmIntentList parameters.
344+
#>
345+
function Test-PPGVMIntentAndZoneFeatures
346+
{
347+
# Setup
348+
$rgname = Get-ComputeTestResourceName;
349+
$loc = "westeurope";
350+
351+
try
352+
{
353+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
354+
355+
# Create a VM first
356+
$ppgname = $rgname + 'ppg';
357+
$vmIntentList1 = 'Standard_D4d_v4';
358+
$vmIntentList2 = 'Standard_D4d_v5';
359+
$vmIntentListUpdate3 = 'Standard_DS3_v2';
360+
$zone = '1';
361+
$zone2 = '2';
362+
363+
$proxgroup = New-AzProximityPlacementGroup -ResourceGroupName $rgname -Name $ppgname -Location $loc -Zone $zone -IntentVMSizeList $vmIntentList1, $vmIntentList2 ;
364+
365+
$ppg = Get-AzProximityPlacementGroup -ResourceGroupName $rgname -Name $ppgname;
366+
Assert-AreEqual $ppg.Intent.VmSizes[0] $vmIntentList1;
367+
Assert-AreEqual $ppg.Intent.VmSizes[1] $vmIntentList2;
368+
Assert-AreEqual $ppg.Zones[0] $zone;
369+
370+
$proxgroup = New-AzProximityPlacementGroup -ResourceGroupName $rgname -Name $ppgname -Location $loc -Zone $zone -IntentVMSizeList $vmIntentList1, $vmIntentListUpdate3 ;
371+
$ppg = Get-AzProximityPlacementGroup -ResourceGroupName $rgname -Name $ppgname;
372+
Assert-AreEqual $ppg.Intent.VmSizes[0] $vmIntentList1;
373+
Assert-AreEqual $ppg.Intent.VmSizes[1] $vmIntentListUpdate3;
374+
375+
# Create a subnet configuration
376+
$subnet = New-AzVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix 192.168.1.0/24;
377+
378+
# Create a virtual network
379+
$vnet = New-AzVirtualNetwork -ResourceGroupName $rgname -Location $loc -Name ('vnet' + $rgname) -AddressPrefix 192.168.0.0/16 -Subnet $subnet;
380+
381+
# Create a public IP address and specify a DNS name
382+
$pip = New-AzPublicIpAddress -ResourceGroupName $rgname -Location $loc -Name ('pubip' + $rgname) -AllocationMethod Static -IdleTimeoutInMinutes 4;
383+
384+
# Create a network security group
385+
$nsg = New-AzNetworkSecurityGroup -ResourceGroupName $rgname -Location $loc -Name ('netsg' + $rgname);
386+
387+
# Create a virtual network card and associate with public IP address and NSG
388+
$nic = New-AzNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc `
389+
-SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -NetworkSecurityGroupId $nsg.Id;
390+
391+
$vmname = 'vm' + $rgname;
392+
$user = "Foo12";
393+
$password = $PLACEHOLDER;
394+
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
395+
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
396+
$vmSize = 'Standard_D4ds_v5';
397+
398+
# Create a virtual machine configuration
399+
$p = New-AzVMConfig -VMName $vmName -VMSize $vmSize -ProximityPlacementGroupId $ppg.Id `
400+
| Set-AzVMOperatingSystem -Windows -ComputerName $vmName -Credential $cred `
401+
| Add-AzVMNetworkInterface -Id $nic.Id;
402+
403+
$publisherName = "MicrosoftWindowsServer";
404+
$offer = "WindowsServer";
405+
$sku = "2019-DataCenter";
406+
$vmconfig = Set-AzVMSourceImage -VM $p -PublisherName $publisherName -Offer $offer -Skus $sku -Version 'latest';
407+
408+
409+
# Create a virtual machine
410+
New-AzVM -ResourceGroupName $rgname -Location $loc -VM $p;
411+
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmName;
412+
Assert-AreEqual $ppg.Id $vm.ProximityPlacementGroup.Id;
413+
414+
$ppg = Get-AzProximityPlacementGroup -ResourceGroupName $rgname -Name $ppgname;
415+
Assert-AreEqual $vm.Id $ppg.VirtualMachines[0].Id;
416+
Assert-AreEqual $vm.ProximityPlacementGroup.Id $ppg.Id;
417+
}
418+
finally
419+
{
420+
# Cleanup
421+
Clean-ResourceGroup $rgname;
422+
}
423+
}

0 commit comments

Comments
 (0)