@@ -337,3 +337,87 @@ function Test-ProximityPlacementGroupVM
337
337
Clean - ResourceGroup $rgname
338
338
}
339
339
}
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