我需要使用 ARM 模板从连接到单个负载均衡器的映像创建 40 个虚拟机。有没有办法指定 VM 资源数量的计数?
我不是在寻找规模集解决方案。
您可以将copyIndex函数用作copyIndex(loopName, offset).
以下示例显示了复制循环和名称中包含的索引值。
{
"apiVersion": "2018-04-01",
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat(parameters('vmNamePrefix'), copyindex())]",
"copy": {
"name": "virtualMachineLoop",
"count": "[variables('numberOfInstances')]"
},
例如,您可以将 更改variables('numberOfInstances')为 40,并注意 Azure VM 名称、osProfile、networkInterfaces 等资源copyIndex()在以下参考模板中应具有唯一名称(包括)。
https://github.com/Azure/azure-quickstart-templates/tree/master/201-2-vms-loadbalancer-lbrules
https://github.com/Azure/azure-quickstart-templates/tree/master/201-2-vms-internal-load-balancer