Creating and using proximity placement groups using PowerShell

Applies to: ✔️ Linux VMs ✔️ Windows VMs ✔️ Uniform scale sets

To get VMs as close as possible, achieving the lowest possible latency, you should deploy your scale set 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.

Get-AzProximityPlacementGroup

Create a scale set

Create a scale in the proximity placement group using -ProximityPlacementGroup $ppg.Id to refer to the proximity placement group ID when you use New-AzVMSS to create the scale set.

$scalesetName = "myVM"

New-AzVmss `
  -ResourceGroupName $resourceGroup `
  -Location $location `
  -VMScaleSetName $scalesetName `
  -VirtualNetworkName "myVnet" `
  -SubnetName "mySubnet" `
  -PublicIpAddressName "myPublicIPAddress" `
  -LoadBalancerName "myLoadBalancer" `
  -UpgradePolicyMode "Automatic" `
  -ProximityPlacementGroup $ppg.Id

You can see the instance in the placement group using Get-AzProximityPlacementGroup.

  Get-AzProximityPlacementGroup `
   -ResourceId $ppg.Id | Format-Table `
   -Wrap `
   -Property VirtualMachineScaleSets

Next steps

You can also use the Azure CLI to create proximity placement groups.