在虚拟机规模集中,可以使用应用网关后端HTTP设置,而不是使用应用网关后端地址池来实现负载均衡。以下是使用应用网关后端HTTP设置的示例代码:
"resources": [
  {
    "type": "Microsoft.Compute/virtualMachineScaleSets",
    "name": "myVMSS",
    "apiVersion": "2019-03-01",
    "location": "[resourceGroup().location]",
    "sku": {
      "name": "Standard_DS1_v2",
      "tier": "Standard",
      "capacity": 2
    },
    "properties": {
      "overprovision": false,
      "upgradePolicy": {
        "mode": "Automatic"
      },
      "virtualMachineProfile": {
        "storageProfile": {
          "osDisk": {
            "caching": "ReadWrite",
            "createOption": "FromImage"
          },
          "imageReference": {
            "publisher": "MicrosoftWindowsServer",
            "offer": "WindowsServer",
            "sku": "2012-R2-Datacenter",
            "version": "latest"
          }
        },
        "osProfile": {
          "computerNamePrefix": "myVMSS",
          "adminUsername": "adminUser",
          "adminPassword": "[parameters('adminPassword')]",
          "customData": "[base64('someCustomData')]"
        },
        "networkProfile": {
          "networkInterfaceConfigurations": [
            {
              "name": "nicConfig",
              "properties": {
                "primary": true,
                "ipConfigurations": [
                  {
                    "name": "ipConfig",
                    "properties": {
                      "subnet": {
                        "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', 'myVnet', 'mySubnet')]"
                      },
                      "loadBalancerBackendAddressPools": [
                        {
                          "id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', 'myLB', 'backendPool')]"
                        }
                      ],
                      "applicationGatewayBackendHttpSettingsCollection": [
                        {
                          "id": "[resourceId