Deploy VMs to proximity placement groups using PowerShell
To get VMs as close as possible, achieving the lowest possible latency, you should deploy them within a proximity placement group.
A proximity placement group is a logical grouping used to make sure that Azure compute resources are physically located close to each other. Proximity placement groups are useful for workloads where low latency is a requirement.
Create a proximity placement group
Create a proximity placement group using the New-AzProximityPlacementGroup cmdlet.
$resourceGroup = "myPPGResourceGroup" $location = "East US" $ppgName = "myPPG" New-AzResourceGroup -Name $resourceGroup -Location $location $ppg = New-AzProximityPlacementGroup ` -Location $location ` -Name $ppgName ` -ResourceGroupName $resourceGroup ` -ProximityPlacementGroupType Standard
List proximity placement groups
You can list all of the proximity placement groups using the Get-AzProximityPlacementGroup cmdlet.
Create a VM
Create a VM in the proximity placement group using
-ProximityPlacementGroup $ppg.Id to refer to the proximity placement group ID when you use New-AzVM to create the VM.
$vmName = "myVM" New-AzVm ` -ResourceGroupName $resourceGroup ` -Name $vmName ` -Location $location ` -OpenPorts 3389 ` -ProximityPlacementGroup $ppg.Id
You can see the VM in the placement group using Get-AzProximityPlacementGroup.
Get-AzProximityPlacementGroup -ResourceId $ppg.Id | Format-Table -Property VirtualMachines -Wrap
You can also create an availability set in your proximity placement group. Use the same
-ProximityPlacementGroup parameter with the New-AzAvailabilitySet cmdlet to create an availability set and all of the VMs created in the availability set will also be created in the same proximity placement group.
You can also create a scale set in your proximity placement group. Use the same
-ProximityPlacementGroup parameter with New-AzVmss to create a scale set and all of the instances will be created in the same proximity placement group.
You can also use the Azure CLI to create proximity placement groups.