Azure 负载均衡器和 Azure 虚拟机规模集Azure Load Balancer with Azure virtual machine scale sets

使用虚拟机规模集和负载均衡器时,应考虑以下准则:When working with virtual machine scale sets and load balancer, the following guidelines should be considered:

端口转发和入站 NAT 规则:Port Forwarding and inbound NAT rules:

  • 创建规模集后,无法为负载均衡器的运行状况探测所用的负载均衡规则修改后端端口。After the scale set has been created, the backend port cannot be modified for a load balancing rule used by a health probe of the load balancer. 为了更改端口,可以通过更新 Azure 虚拟机规模集来删除运行状况探测,更新端口,然后重新配置运行状况探测。To change the port, you can remove the health probe by updating the Azure virtual machine scale set, update the port and then configure the health probe again.
  • 在负载均衡器的后端池中使用虚拟机规模集时,会自动创建默认的入站 NAT 规则。When using the virtual machine scale set in the backend pool of the load balancer, the default inbound NAT rules get created automatically.

入站 NAT 池:Inbound NAT pool:

  • 每个虚拟机规模集必须有至少一个入站 NAT 池。Each virtual machine scale set must have at least one inbound NAT pool.
  • 入站 NAT 池是入站 NAT 规则的集合。Inbound NAT pool is a collection of inbound NAT rules. 一个入站 NAT 池不能支持多个虚拟机规模集。One inbound NAT pool cannot support multiple virtual machine scales sets.
  • 若要从现有虚拟机规模集中删除 NAT 池,需要先从规模集中删除 NAT 池。In order to delete a NAT pool from an existing virtual machine scale set, you need to first remove the NAT pool from the scale set. 下面显示了一个使用 CLI 的完整示例:A full example using CLI is shown below:
  az vmss update
     --resource-group MyResourceGroup
     --name MyVMSS
     --remove virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].ipConfigurations[0].loadBalancerInboundNatPools
  az vmss update-instances
     --instance-ids *
     --resource-group MyResourceGroup
     --name MyVMSS
  az network lb inbound-nat-pool delete
     --resource-group MyResourceGroup
     --lb-name MyLoadBalancer
     --name MyNatPool

负载均衡规则:Load balancing rules:

  • 在负载均衡器的后端池中使用虚拟机规模集时,会自动创建默认的负载均衡规则。When using the virtual machine scale set in the backend pool of the load balancer, the default load balancing rule gets created automatically.

出站规则:Outbound rules:

  • 若要为已被负载均衡规则引用的后端池创建出站规则,需要先在创建入站负载均衡规则时在门户中将“创建隐式出站规则”标记为“否”。 To create outbound rule for a backend pool that is already referenced by a load balancing rule, you need to first mark "Create implicit outbound rules" as No in the portal when the inbound load balancing rule is created.

创建负载均衡规则

可以使用以下方法部署一个包含现有 Azure 负载均衡器的虚拟机规模集。The following methods can be used to deploy a virtual machine scale set with an existing Azure load balancer.