使用 Azure CLI 将 VM 部署到邻近放置组Deploy VMs to proximity placement groups using Azure CLI

若要让 VM 尽可能靠近,将延迟尽可能降至最低,应将 VM 部署到一个邻近放置组中。To get VMs as close as possible, achieving the lowest possible latency, you should deploy them within a proximity placement group.

邻近放置组是一种逻辑分组,用于确保 Azure 计算资源在物理上彼此靠近。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

使用 az ppg create 创建邻近放置组。Create a proximity placement group using az ppg create.

az group create --name myPPGGroup --location chinanorth
az ppg create \
   -n myPPG \
   -g myPPGGroup \
   -l chinanorth \
   -t standard 

列出邻近放置组List proximity placement groups

可以使用 az ppg list 来列出所有邻近放置组。You can list all of your proximity placement groups using az ppg list.

az ppg list -o table

创建 VMCreate a VM

使用 new az vm 在邻近放置组中创建 VM。Create a VM within the proximity placement group using new az vm.

az vm create \
   -n myVM \
   -g myPPGGroup \
   --image UbuntuLTS \
   --ppg myPPG  \
   --generate-ssh-keys \
   --size Standard_D1_v2  \
   -l chinanorth

可以使用 az ppg show 查看邻近放置组中的 VM。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. 将同一 --ppg 参数与 az vm availability-set create 一起使用来创建一个可用性集,并且也将在同一邻近放置组中创建该可用性集中的所有 VM。Use the same --ppg parameter with az vm availability-set create to create an availability set and all of the VMs in the availability set will also be created in the same proximity placement group.

规模集Scale sets

还可以在邻近放置组中创建规模集。You can also create a scale set in your proximity placement group. 将同一 --ppg 参数与 az vmss create 一起使用来创建规模集,并且将在同一邻近放置组中创建所有实例。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

详细了解用于邻近放置组的 Azure CLI 命令。Learn more about the Azure CLI commands for proximity placement groups.