Muokkaa

Jaa


Deploy VMs to proximity placement groups using Azure CLI

Applies to: ✔️ Linux VMs ✔️ Flexible scale sets

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 the proximity placement group

Create a proximity placement group using az ppg create.

az group create --name myPPGGroup --location eastus
az ppg create \
   -n myPPG \
   -g myPPGGroup \
   -l eastus \
   -t standard \
   --intent-vm-sizes Standard_E64s_v4 Standard_M416ms_v2 \
   -z 1

List proximity placement groups

You can list all of your proximity placement groups using az ppg list.

az ppg list -o table

Show proximity placement group

You can see the proximity placement group details and resources using az ppg show

az ppg show --name myPPG --resource-group myPPGGroup
{  "availabilitySets": [],  
   "colocationStatus": null,  
   "id": "/subscriptions/[subscriptionId]/resourceGroups/myPPGGroup/providers/Microsoft.Compute/proximityPlacementGroups/MyPPG",  
   "intent": {    
    "vmSizes": [      
      "Standard_E64s_v4",      
      "Standard_M416ms_v2"    
    ]  
   },  
   "location": "eastus",  
   "name": "MyPPG",  
   "proximityPlacementGroupType": "Standard",  
   "resourceGroup": "myPPGGroup",  
   "tags": {},  
   "type": "Microsoft.Compute/proximityPlacementGroups",  
   "virtualMachineScaleSets": [],  
   "virtualMachines": [],  
   "zones": [    
    "1" 
   ]
}

Create a VM

Important

Starting November 2023, VM scale sets created using PowerShell and Azure CLI will default to Flexible Orchestration Mode if no orchestration mode is specified. For more information about this change and what actions you should take, go to Breaking Change for VMSS PowerShell/CLI Customers - Microsoft Community Hub

Create a VM within the proximity placement group using new az vm.

az vm create \
   -n myVM \
   -g myPPGGroup \
   --image Ubuntu2204 \
   --orchestration-mode "Uniform"
   --ppg myPPG  \
   --generate-ssh-keys \
   --size Standard_E64s_v4 \
   -l eastus

You can see the VM in the proximity placement group using az ppg show.

az ppg show --name myppg --resource-group myppggroup --query "virtualMachines"

Availability Sets

You can also create an availability set in your proximity placement group. Use the same --ppg parameter with az vm availability-set create to add all VMs in the availability set to the same proximity placement group.

Scale sets

You can also create a scale set in your proximity placement group. Use the same --ppg parameter with az vmss create to create a scale set and all of the instances will be created in the same proximity placement group.

Next steps

Learn more about the Azure CLI commands for proximity placement groups.