Tutorial: Bereitstellen eines globalen Lastenausgleichs mit Azure Resource Manager-Vorlagen

Ein globaler Lastenausgleich stellt sicher, dass ein Dienst global in mehreren Azure-Regionen verfügbar ist. Wenn eine Region ausfällt, wird der Datenverkehr an den nächstgelegenen fehlerfreien Lastenausgleich weitergeleitet.

Bei Verwendung einer ARM-Vorlage werden im Vergleich zu anderen Bereitstellungsmethoden weniger Schritte benötigt.

Eine Azure Resource Manager-Vorlage ist eine JSON (JavaScript Object Notation)-Datei, welche die Infrastruktur und die Konfiguration für Ihr Projekt definiert. Die Vorlage verwendet eine deklarative Syntax. Sie beschreiben Ihre geplante Bereitstellung, ohne die Abfolge der Programmierbefehle zum Erstellen der Bereitstellung zu schreiben.

Wenn Ihre Umgebung die Voraussetzungen erfüllt und Sie mit der Verwendung von ARM-Vorlagen vertraut sind, klicken Sie auf die Schaltfläche In Azure bereitstellen. Die Vorlage wird im Azure-Portal geöffnet.

Schaltfläche zum Bereitstellen der Resource Manager-Vorlage in Azure.

In diesem Tutorial lernen Sie Folgendes:

  • Alle Tutorials enthalten eine Liste mit einer Zusammenfassung der auszuführenden Schritte.
  • Jeder dieser Aufzählungspunkte wird an einem Schlüssel (H2) ausgerichtet.
  • Verwenden Sie diese grünen Kontrollkästchen in einem Tutorial.

Voraussetzungen

Überprüfen der Vorlage

In diesem Abschnitt überprüfen Sie die Vorlage und die Parameter, die zum Bereitstellen des globalen Lastenausgleichs verwendet werden. Die in dieser Schnellstartanleitung verwendete Vorlage stammt aus den Azure-Schnellstartvorlagen.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.26.54.24096",
      "templateHash": "15686909125702100557"
    }
  },
  "parameters": {
    "projectName": {
      "type": "string",
      "metadata": {
        "description": "Specifies a project name that is used for generating resource names."
      }
    },
    "locationCr": {
      "type": "string",
      "defaultValue": "eastus2",
      "allowedValues": [
        "eastus2",
        "westus",
        "centralus",
        "westeurope",
        "southeastasia",
        "centralus",
        "northeurope",
        "eastasia",
        "UKsouth",
        "USgovvirginia"
      ],
      "metadata": {
        "description": "Specifies the location for the cross-region load balancer.  Available in limited regions."
      }
    },
    "locationR1": {
      "type": "string",
      "defaultValue": "eastus",
      "allowedValues": [
        "eastus",
        "eastus2",
        "southcentralus",
        "westus2",
        "westus3",
        "australiaeast",
        "southeastasia",
        "northeurope",
        "swedencentral",
        "uksouth",
        "westeurope",
        "centralus",
        "southafricanorth",
        "centralindia",
        "eastasia",
        "japaneast",
        "koreacentral",
        "canadacentral",
        "francecentral",
        "germanywestcentral",
        "norwayeast",
        "switzerlandnorth",
        "uaenorth",
        "brazilsouth",
        "eastus2euap",
        "qatarcentral",
        "centralusstage",
        "eastus2stage",
        "northcentralusstage",
        "southcentralusstage",
        "westusstage",
        "westus2stage",
        "asia",
        "asiapacific",
        "australia",
        "brazil",
        "canada",
        "europe",
        "france",
        "germany",
        "global",
        "india",
        "japan",
        "korea",
        "norway",
        "singapore",
        "southafrica",
        "switzerland",
        "unitedstates",
        "eastasiastage",
        "eastusstg",
        "northcentralus",
        "westus",
        "jioindiawest",
        "centraluseuap",
        "westcentralus",
        "southafricawest",
        "australiacentral",
        "australiacentral2",
        "australiasoutheast",
        "japanwest",
        "jioindiacentral",
        "koreasouth",
        "southindia",
        "westindia",
        "francesouth",
        "germanynorth",
        "norwaywest",
        "switzerlandwest",
        "ukwest",
        "uaecentral",
        "brazilsoutheast"
      ],
      "metadata": {
        "description": "Specifies the location for the regional load balancer."
      }
    },
    "locationR2": {
      "type": "string",
      "defaultValue": "westus2",
      "allowedValues": [
        "eastus",
        "eastus2",
        "southcentralus",
        "westus2",
        "westus3",
        "australiaeast",
        "southeastasia",
        "northeurope",
        "swedencentral",
        "uksouth",
        "westeurope",
        "centralus",
        "southafricanorth",
        "centralindia",
        "eastasia",
        "japaneast",
        "koreacentral",
        "canadacentral",
        "francecentral",
        "germanywestcentral",
        "norwayeast",
        "switzerlandnorth",
        "uaenorth",
        "brazilsouth",
        "eastus2euap",
        "qatarcentral",
        "centralusstage",
        "eastus2stage",
        "northcentralusstage",
        "southcentralusstage",
        "westusstage",
        "westus2stage",
        "asia",
        "asiapacific",
        "australia",
        "brazil",
        "canada",
        "europe",
        "france",
        "germany",
        "global",
        "india",
        "japan",
        "korea",
        "norway",
        "singapore",
        "southafrica",
        "switzerland",
        "unitedstates",
        "eastasiastage",
        "eastusstg",
        "northcentralus",
        "westus",
        "jioindiawest",
        "centraluseuap",
        "westcentralus",
        "southafricawest",
        "australiacentral",
        "australiacentral2",
        "australiasoutheast",
        "japanwest",
        "jioindiacentral",
        "koreasouth",
        "southindia",
        "westindia",
        "francesouth",
        "germanynorth",
        "norwaywest",
        "switzerlandwest",
        "ukwest",
        "uaecentral",
        "brazilsoutheast"
      ],
      "metadata": {
        "description": "Specifies the location for the regional load balancer."
      }
    },
    "adminUsername": {
      "type": "string",
      "metadata": {
        "description": "Specifies the virtual machine administrator username."
      }
    },
    "adminPassword": {
      "type": "securestring",
      "metadata": {
        "description": "Specifies the virtual machine administrator password."
      }
    },
    "vmSize": {
      "type": "string",
      "defaultValue": "Standard_DS1_v2",
      "metadata": {
        "description": "Size of the virtual machine"
      }
    }
  },
  "variables": {
    "publicIPAddressType": "Static",
    "lbSkuName": "Standard",
    "vmStorageAccountType": "Premium_LRS",
    "lbR1Name": "[format('{0}-lb-r1', parameters('projectName'))]",
    "lbPIPR1Name": "[format('{0}-lbPublicIP-r1', parameters('projectName'))]",
    "lbFrontEndR1Name": "LoadBalancerFrontEnd-r1",
    "lbBackendPoolR1Name": "LoadBalancerBackEndPool-r1",
    "lbProbeR1Name": "loadBalancerHealthProbe-r1",
    "nsgR1Name": "[format('{0}-nsg-r1', parameters('projectName'))]",
    "vnetR1Name": "[format('{0}-vnet-r1', parameters('projectName'))]",
    "vnetAddressPrefixR1": "10.0.0.0/16",
    "vnetSubnetR1Name": "BackendSubnet-r1",
    "vnetSubnetAddressPrefixR1": "10.0.0.0/24",
    "bastionHostR1Name": "[format('{0}-bastion-r1', parameters('projectName'))]",
    "bastionSubnetR1Name": "AzureBastionSubnet",
    "vnetBastionSubnetAddressPrefixR1": "10.0.1.0/26",
    "bastionPIPR1Name": "[format('{0}-bastionPublicIP-r1', parameters('projectName'))]",
    "natGatewayR1Name": "[format('{0}-natgateway-r1', parameters('projectName'))]",
    "natGatewayPIR1Name": "[format('{0}-natPublicIP-r1', parameters('projectName'))]",
    "lbR2Name": "[format('{0}-lb-r2', parameters('projectName'))]",
    "lbPIPR2Name": "[format('{0}-lbPublicIP-r2', parameters('projectName'))]",
    "lbFrontEndR2Name": "LoadBalancerFrontEnd-r2",
    "lbBackendPoolR2Name": "LoadBalancerBackEndPool-r2",
    "lbProbeR2Name": "loadBalancerHealthProbe-r2",
    "nsgR2Name": "[format('{0}-nsg-r2', parameters('projectName'))]",
    "vnetR2Name": "[format('{0}-vnet-r2', parameters('projectName'))]",
    "vnetAddressPrefixR2": "10.1.0.0/16",
    "vnetSubnetR2Name": "BackendSubnet-r2",
    "vnetSubnetAddressPrefixR2": "10.1.0.0/24",
    "bastionHostR2Name": "[format('{0}-bastion-r2', parameters('projectName'))]",
    "bastionSubnetR2Name": "AzureBastionSubnet",
    "vnetBastionSubnetAddressPrefixR2": "10.1.1.0/26",
    "bastionPIPR2Name": "[format('{0}-bastionPublicIP-r2', parameters('projectName'))]",
    "natGatewayR2Name": "[format('{0}-natgateway-r2', parameters('projectName'))]",
    "natGatewayPIR2Name": "[format('{0}-natPublicIP-r2', parameters('projectName'))]",
    "lbCrName": "[format('{0}-lb-cr', parameters('projectName'))]",
    "lbBackendPoolCrName": "LoadBalancerBackEndPool-cr",
    "lbPIPCrName": "[format('{0}-lbPublicIP-cr', parameters('projectName'))]",
    "lbFrontEndCrName": "LoadBalancerFrontEnd-cr"
  },
  "resources": [
    {
      "copy": {
        "name": "nicVmR1",
        "count": "[length(range(0, 3))]"
      },
      "type": "Microsoft.Network/networkInterfaces",
      "apiVersion": "2023-02-01",
      "name": "[format('vm-r1-{0}-networkInterface', add(range(0, 3)[copyIndex()], 1))]",
      "location": "[parameters('locationR1')]",
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig1",
            "properties": {
              "privateIPAllocationMethod": "Dynamic",
              "subnet": {
                "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetR1Name'), variables('vnetSubnetR1Name'))]"
              },
              "loadBalancerBackendAddressPools": [
                {
                  "id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('lbR1Name'), variables('lbBackendPoolR1Name'))]"
                }
              ]
            }
          }
        ],
        "networkSecurityGroup": {
          "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgR1Name'))]"
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/loadBalancers', variables('lbR1Name'))]",
        "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgR1Name'))]",
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetR1Name'))]",
        "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetR1Name'), variables('vnetSubnetR1Name'))]"
      ]
    },
    {
      "copy": {
        "name": "installWebServerVmR1",
        "count": "[length(range(0, 3))]"
      },
      "type": "Microsoft.Compute/virtualMachines/extensions",
      "apiVersion": "2023-03-01",
      "name": "[format('vm-r1-{0}/InstallWebServer', add(range(0, 3)[copyIndex()], 1))]",
      "location": "[parameters('locationR1')]",
      "properties": {
        "publisher": "Microsoft.Compute",
        "type": "CustomScriptExtension",
        "typeHandlerVersion": "1.7",
        "autoUpgradeMinorVersion": true,
        "settings": {
          "commandToExecute": "powershell.exe Install-WindowsFeature -name Web-Server -IncludeManagementTools && powershell.exe remove-item 'C:\\inetpub\\wwwroot\\iisstart.htm' && powershell.exe Add-Content -Path 'C:\\inetpub\\wwwroot\\iisstart.htm' -Value $('Hello World from ' + $env:computername)"
        }
      },
      "dependsOn": [
        "vmR2"
      ]
    },
    {
      "copy": {
        "name": "vmR1",
        "count": "[length(range(0, 3))]"
      },
      "type": "Microsoft.Compute/virtualMachines",
      "apiVersion": "2023-03-01",
      "name": "[format('vm-r1-{0}', add(range(0, 3)[copyIndex()], 1))]",
      "location": "[parameters('locationR1')]",
      "properties": {
        "hardwareProfile": {
          "vmSize": "[parameters('vmSize')]"
        },
        "storageProfile": {
          "imageReference": {
            "publisher": "MicrosoftWindowsServer",
            "offer": "WindowsServer",
            "sku": "2019-Datacenter",
            "version": "latest"
          },
          "osDisk": {
            "createOption": "fromImage",
            "managedDisk": {
              "storageAccountType": "[variables('vmStorageAccountType')]"
            }
          }
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces', format('vm-r1-{0}-networkInterface', add(range(0, 3)[copyIndex()], 1)))]"
            }
          ]
        },
        "osProfile": {
          "computerName": "[format('vm-r1-{0}', add(range(0, 3)[copyIndex()], 1))]",
          "adminUsername": "[parameters('adminUsername')]",
          "adminPassword": "[parameters('adminPassword')]",
          "windowsConfiguration": {
            "enableAutomaticUpdates": true,
            "provisionVMAgent": true
          }
        }
      },
      "dependsOn": [
        "nicVmR2"
      ]
    },
    {
      "type": "Microsoft.Network/virtualNetworks/subnets",
      "apiVersion": "2023-02-01",
      "name": "[format('{0}/{1}', variables('vnetR1Name'), variables('bastionSubnetR1Name'))]",
      "properties": {
        "addressPrefix": "[variables('vnetBastionSubnetAddressPrefixR1')]"
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetR1Name'))]"
      ]
    },
    {
      "type": "Microsoft.Network/virtualNetworks/subnets",
      "apiVersion": "2023-02-01",
      "name": "[format('{0}/{1}', variables('vnetR1Name'), variables('vnetSubnetR1Name'))]",
      "properties": {
        "addressPrefix": "[variables('vnetSubnetAddressPrefixR1')]",
        "natGateway": {
          "id": "[resourceId('Microsoft.Network/natGateways', variables('natGatewayR1Name'))]"
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/natGateways', variables('natGatewayR1Name'))]",
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetR1Name'))]",
        "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetR1Name'), variables('bastionSubnetR1Name'))]"
      ]
    },
    {
      "type": "Microsoft.Network/bastionHosts",
      "apiVersion": "2023-02-01",
      "name": "[variables('bastionHostR1Name')]",
      "location": "[parameters('locationR1')]",
      "properties": {
        "ipConfigurations": [
          {
            "name": "IpConf",
            "properties": {
              "privateIPAllocationMethod": "Dynamic",
              "publicIPAddress": {
                "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('bastionPIPR1Name'))]"
              },
              "subnet": {
                "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetR1Name'), variables('bastionSubnetR1Name'))]"
              }
            }
          }
        ]
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/publicIPAddresses', variables('bastionPIPR1Name'))]",
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetR1Name'))]",
        "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetR1Name'), variables('bastionSubnetR1Name'))]"
      ]
    },
    {
      "type": "Microsoft.Network/publicIPAddresses",
      "apiVersion": "2023-02-01",
      "name": "[variables('bastionPIPR1Name')]",
      "location": "[parameters('locationR1')]",
      "sku": {
        "name": "[variables('lbSkuName')]"
      },
      "properties": {
        "publicIPAddressVersion": "IPv4",
        "publicIPAllocationMethod": "Static"
      }
    },
    {
      "type": "Microsoft.Network/natGateways",
      "apiVersion": "2021-05-01",
      "name": "[variables('natGatewayR1Name')]",
      "location": "[parameters('locationR1')]",
      "sku": {
        "name": "Standard"
      },
      "properties": {
        "idleTimeoutInMinutes": 4,
        "publicIpAddresses": [
          {
            "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('natGatewayPIR1Name'))]"
          }
        ]
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/publicIPAddresses', variables('natGatewayPIR1Name'))]"
      ]
    },
    {
      "type": "Microsoft.Network/publicIPAddresses",
      "apiVersion": "2021-05-01",
      "name": "[variables('natGatewayPIR1Name')]",
      "location": "[parameters('locationR1')]",
      "sku": {
        "name": "Standard"
      },
      "properties": {
        "publicIPAddressVersion": "IPv4",
        "publicIPAllocationMethod": "Static",
        "idleTimeoutInMinutes": 4
      }
    },
    {
      "type": "Microsoft.Network/loadBalancers",
      "apiVersion": "2023-02-01",
      "name": "[variables('lbR1Name')]",
      "location": "[parameters('locationR1')]",
      "sku": {
        "name": "[variables('lbSkuName')]"
      },
      "properties": {
        "frontendIPConfigurations": [
          {
            "name": "[variables('lbFrontEndR1Name')]",
            "properties": {
              "publicIPAddress": {
                "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('lbPIPR1Name'))]"
              }
            }
          }
        ],
        "backendAddressPools": [
          {
            "name": "[variables('lbBackendPoolR1Name')]"
          }
        ],
        "loadBalancingRules": [
          {
            "name": "myHTTPRule",
            "properties": {
              "frontendIPConfiguration": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('lbR1Name'), variables('lbFrontEndR1Name'))]"
              },
              "backendAddressPool": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('lbR1Name'), variables('lbBackendPoolR1Name'))]"
              },
              "frontendPort": 80,
              "backendPort": 80,
              "enableFloatingIP": false,
              "idleTimeoutInMinutes": 15,
              "protocol": "Tcp",
              "enableTcpReset": true,
              "loadDistribution": "Default",
              "disableOutboundSnat": true,
              "probe": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/probes', variables('lbR1Name'), variables('lbProbeR1Name'))]"
              }
            }
          }
        ],
        "probes": [
          {
            "name": "[variables('lbProbeR1Name')]",
            "properties": {
              "protocol": "Http",
              "port": 80,
              "requestPath": "/",
              "intervalInSeconds": 5,
              "numberOfProbes": 2
            }
          }
        ],
        "outboundRules": []
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/publicIPAddresses', variables('lbPIPR1Name'))]"
      ]
    },
    {
      "type": "Microsoft.Network/publicIPAddresses",
      "apiVersion": "2023-02-01",
      "name": "[variables('lbPIPR1Name')]",
      "location": "[parameters('locationR1')]",
      "sku": {
        "name": "[variables('lbSkuName')]"
      },
      "properties": {
        "publicIPAddressVersion": "IPv4",
        "publicIPAllocationMethod": "Static"
      }
    },
    {
      "type": "Microsoft.Network/networkSecurityGroups",
      "apiVersion": "2023-02-01",
      "name": "[variables('nsgR1Name')]",
      "location": "[parameters('locationR1')]",
      "properties": {
        "securityRules": [
          {
            "name": "AllowHTTPInbound",
            "properties": {
              "protocol": "*",
              "sourcePortRange": "*",
              "destinationPortRange": "80",
              "sourceAddressPrefix": "Internet",
              "destinationAddressPrefix": "*",
              "access": "Allow",
              "priority": 100,
              "direction": "Inbound"
            }
          }
        ]
      }
    },
    {
      "type": "Microsoft.Network/virtualNetworks",
      "apiVersion": "2023-02-01",
      "name": "[variables('vnetR1Name')]",
      "location": "[parameters('locationR1')]",
      "properties": {
        "addressSpace": {
          "addressPrefixes": [
            "[variables('vnetAddressPrefixR1')]"
          ]
        }
      }
    },
    {
      "copy": {
        "name": "nicVmR2",
        "count": "[length(range(0, 3))]"
      },
      "type": "Microsoft.Network/networkInterfaces",
      "apiVersion": "2023-02-01",
      "name": "[format('vm-r2-{0}-networkInterface', add(range(0, 3)[copyIndex()], 1))]",
      "location": "[parameters('locationR2')]",
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig1",
            "properties": {
              "privateIPAllocationMethod": "Dynamic",
              "subnet": {
                "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetR2Name'), variables('vnetSubnetR2Name'))]"
              },
              "loadBalancerBackendAddressPools": [
                {
                  "id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('lbR2Name'), variables('lbBackendPoolR2Name'))]"
                }
              ]
            }
          }
        ],
        "networkSecurityGroup": {
          "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgR2Name'))]"
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/loadBalancers', variables('lbR2Name'))]",
        "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgR2Name'))]",
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetR2Name'))]",
        "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetR2Name'), variables('vnetSubnetR2Name'))]"
      ]
    },
    {
      "copy": {
        "name": "installWebServerVmR2",
        "count": "[length(range(0, 3))]"
      },
      "type": "Microsoft.Compute/virtualMachines/extensions",
      "apiVersion": "2023-03-01",
      "name": "[format('vm-r2-{0}/InstallWebServer', add(range(0, 3)[copyIndex()], 1))]",
      "location": "[parameters('locationR2')]",
      "properties": {
        "publisher": "Microsoft.Compute",
        "type": "CustomScriptExtension",
        "typeHandlerVersion": "1.7",
        "autoUpgradeMinorVersion": true,
        "settings": {
          "commandToExecute": "powershell.exe Install-WindowsFeature -name Web-Server -IncludeManagementTools && powershell.exe remove-item 'C:\\inetpub\\wwwroot\\iisstart.htm' && powershell.exe Add-Content -Path 'C:\\inetpub\\wwwroot\\iisstart.htm' -Value $('Hello World from ' + $env:computername)"
        }
      },
      "dependsOn": [
        "vmR2"
      ]
    },
    {
      "copy": {
        "name": "vmR2",
        "count": "[length(range(0, 3))]"
      },
      "type": "Microsoft.Compute/virtualMachines",
      "apiVersion": "2023-03-01",
      "name": "[format('vm-r2-{0}', add(range(0, 3)[copyIndex()], 1))]",
      "location": "[parameters('locationR2')]",
      "properties": {
        "hardwareProfile": {
          "vmSize": "[parameters('vmSize')]"
        },
        "storageProfile": {
          "imageReference": {
            "publisher": "MicrosoftWindowsServer",
            "offer": "WindowsServer",
            "sku": "2019-Datacenter",
            "version": "latest"
          },
          "osDisk": {
            "createOption": "fromImage",
            "managedDisk": {
              "storageAccountType": "[variables('vmStorageAccountType')]"
            }
          }
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces', format('vm-r2-{0}-networkInterface', add(range(0, 3)[copyIndex()], 1)))]"
            }
          ]
        },
        "osProfile": {
          "computerName": "[format('vm-r2-{0}', add(range(0, 3)[copyIndex()], 1))]",
          "adminUsername": "[parameters('adminUsername')]",
          "adminPassword": "[parameters('adminPassword')]",
          "windowsConfiguration": {
            "enableAutomaticUpdates": true,
            "provisionVMAgent": true
          }
        }
      },
      "dependsOn": [
        "nicVmR2"
      ]
    },
    {
      "type": "Microsoft.Network/virtualNetworks/subnets",
      "apiVersion": "2023-02-01",
      "name": "[format('{0}/{1}', variables('vnetR2Name'), variables('bastionSubnetR2Name'))]",
      "properties": {
        "addressPrefix": "[variables('vnetBastionSubnetAddressPrefixR2')]"
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetR2Name'))]"
      ]
    },
    {
      "type": "Microsoft.Network/virtualNetworks/subnets",
      "apiVersion": "2023-02-01",
      "name": "[format('{0}/{1}', variables('vnetR2Name'), variables('vnetSubnetR2Name'))]",
      "properties": {
        "addressPrefix": "[variables('vnetSubnetAddressPrefixR2')]",
        "natGateway": {
          "id": "[resourceId('Microsoft.Network/natGateways', variables('natGatewayR2Name'))]"
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/natGateways', variables('natGatewayR2Name'))]",
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetR2Name'))]",
        "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetR2Name'), variables('bastionSubnetR2Name'))]"
      ]
    },
    {
      "type": "Microsoft.Network/bastionHosts",
      "apiVersion": "2023-02-01",
      "name": "[variables('bastionHostR2Name')]",
      "location": "[parameters('locationR2')]",
      "properties": {
        "ipConfigurations": [
          {
            "name": "IpConf",
            "properties": {
              "privateIPAllocationMethod": "Dynamic",
              "publicIPAddress": {
                "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('bastionPIPR2Name'))]"
              },
              "subnet": {
                "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetR2Name'), variables('bastionSubnetR2Name'))]"
              }
            }
          }
        ]
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/publicIPAddresses', variables('bastionPIPR2Name'))]",
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetR2Name'))]",
        "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetR2Name'), variables('bastionSubnetR2Name'))]"
      ]
    },
    {
      "type": "Microsoft.Network/publicIPAddresses",
      "apiVersion": "2023-02-01",
      "name": "[variables('bastionPIPR2Name')]",
      "location": "[parameters('locationR2')]",
      "sku": {
        "name": "[variables('lbSkuName')]"
      },
      "properties": {
        "publicIPAddressVersion": "IPv4",
        "publicIPAllocationMethod": "Static"
      }
    },
    {
      "type": "Microsoft.Network/natGateways",
      "apiVersion": "2021-05-01",
      "name": "[variables('natGatewayR2Name')]",
      "location": "[parameters('locationR2')]",
      "sku": {
        "name": "Standard"
      },
      "properties": {
        "idleTimeoutInMinutes": 4,
        "publicIpAddresses": [
          {
            "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('natGatewayPIR2Name'))]"
          }
        ]
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/publicIPAddresses', variables('natGatewayPIR2Name'))]"
      ]
    },
    {
      "type": "Microsoft.Network/publicIPAddresses",
      "apiVersion": "2021-05-01",
      "name": "[variables('natGatewayPIR2Name')]",
      "location": "[parameters('locationR2')]",
      "sku": {
        "name": "Standard"
      },
      "properties": {
        "publicIPAddressVersion": "IPv4",
        "publicIPAllocationMethod": "Static",
        "idleTimeoutInMinutes": 4
      }
    },
    {
      "type": "Microsoft.Network/loadBalancers",
      "apiVersion": "2023-02-01",
      "name": "[variables('lbR2Name')]",
      "location": "[parameters('locationR2')]",
      "sku": {
        "name": "[variables('lbSkuName')]"
      },
      "properties": {
        "frontendIPConfigurations": [
          {
            "name": "[variables('lbFrontEndR2Name')]",
            "properties": {
              "publicIPAddress": {
                "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('lbPIPR2Name'))]"
              }
            }
          }
        ],
        "backendAddressPools": [
          {
            "name": "[variables('lbBackendPoolR2Name')]"
          }
        ],
        "loadBalancingRules": [
          {
            "name": "myHTTPRule",
            "properties": {
              "frontendIPConfiguration": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('lbR2Name'), variables('lbFrontEndR2Name'))]"
              },
              "backendAddressPool": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('lbR2Name'), variables('lbBackendPoolR2Name'))]"
              },
              "frontendPort": 80,
              "backendPort": 80,
              "enableFloatingIP": false,
              "idleTimeoutInMinutes": 15,
              "protocol": "Tcp",
              "enableTcpReset": true,
              "loadDistribution": "Default",
              "disableOutboundSnat": true,
              "probe": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/probes', variables('lbR2Name'), variables('lbProbeR2Name'))]"
              }
            }
          }
        ],
        "probes": [
          {
            "name": "[variables('lbProbeR2Name')]",
            "properties": {
              "protocol": "Http",
              "port": 80,
              "requestPath": "/",
              "intervalInSeconds": 5,
              "numberOfProbes": 2
            }
          }
        ],
        "outboundRules": []
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/publicIPAddresses', variables('lbPIPR2Name'))]"
      ]
    },
    {
      "type": "Microsoft.Network/publicIPAddresses",
      "apiVersion": "2023-02-01",
      "name": "[variables('lbPIPR2Name')]",
      "location": "[parameters('locationR2')]",
      "sku": {
        "name": "[variables('lbSkuName')]"
      },
      "properties": {
        "publicIPAddressVersion": "IPv4",
        "publicIPAllocationMethod": "Static"
      }
    },
    {
      "type": "Microsoft.Network/networkSecurityGroups",
      "apiVersion": "2023-02-01",
      "name": "[variables('nsgR2Name')]",
      "location": "[parameters('locationR2')]",
      "properties": {
        "securityRules": [
          {
            "name": "AllowHTTPInbound",
            "properties": {
              "protocol": "*",
              "sourcePortRange": "*",
              "destinationPortRange": "80",
              "sourceAddressPrefix": "Internet",
              "destinationAddressPrefix": "*",
              "access": "Allow",
              "priority": 100,
              "direction": "Inbound"
            }
          }
        ]
      }
    },
    {
      "type": "Microsoft.Network/virtualNetworks",
      "apiVersion": "2023-02-01",
      "name": "[variables('vnetR2Name')]",
      "location": "[parameters('locationR2')]",
      "properties": {
        "addressSpace": {
          "addressPrefixes": [
            "[variables('vnetAddressPrefixR2')]"
          ]
        }
      }
    },
    {
      "type": "Microsoft.Network/publicIPAddresses",
      "apiVersion": "2023-02-01",
      "name": "[variables('lbPIPCrName')]",
      "location": "[parameters('locationCr')]",
      "sku": {
        "name": "Standard",
        "tier": "Global"
      },
      "properties": {
        "publicIPAllocationMethod": "[variables('publicIPAddressType')]"
      }
    },
    {
      "type": "Microsoft.Network/loadBalancers",
      "apiVersion": "2023-02-01",
      "name": "[variables('lbCrName')]",
      "location": "[parameters('locationCr')]",
      "sku": {
        "name": "Standard",
        "tier": "Global"
      },
      "properties": {
        "frontendIPConfigurations": [
          {
            "name": "[variables('lbFrontEndCrName')]",
            "properties": {
              "publicIPAddress": {
                "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('lbPIPCrName'))]"
              }
            }
          }
        ],
        "backendAddressPools": [
          {
            "name": "[variables('lbBackendPoolCrName')]"
          }
        ],
        "loadBalancingRules": [
          {
            "name": "LBRule",
            "properties": {
              "frontendIPConfiguration": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('lbCrName'), variables('lbFrontEndCrName'))]"
              },
              "backendAddressPool": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('lbCrName'), variables('lbBackendPoolCrName'))]"
              },
              "protocol": "Tcp",
              "frontendPort": 80,
              "backendPort": 80,
              "enableFloatingIP": false
            }
          }
        ]
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/publicIPAddresses', variables('lbPIPCrName'))]"
      ]
    },
    {
      "type": "Microsoft.Network/loadBalancers/backendAddressPools",
      "apiVersion": "2023-02-01",
      "name": "[format('{0}/{1}', variables('lbCrName'), variables('lbBackendPoolCrName'))]",
      "properties": {
        "loadBalancerBackendAddresses": [
          {
            "name": "address1",
            "properties": {
              "loadBalancerFrontendIPConfiguration": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('lbR1Name'), variables('lbFrontEndR1Name'))]"
              }
            }
          },
          {
            "name": "address2",
            "properties": {
              "loadBalancerFrontendIPConfiguration": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('lbR2Name'), variables('lbFrontEndR2Name'))]"
              }
            }
          }
        ]
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/loadBalancers', variables('lbCrName'))]",
        "[resourceId('Microsoft.Network/loadBalancers', variables('lbR1Name'))]",
        "[resourceId('Microsoft.Network/loadBalancers', variables('lbR2Name'))]"
      ]
    }
  ]
}

Hinweis

Wenn Sie einen Lastenausgleich im Tarif „Standard“ erstellen, müssen Sie auch eine neue öffentliche Standard-IP-Adresse erstellen, die als Front-End für diesen Standard-Lastenausgleich konfiguriert ist. Außerdem müssen die Lastenausgleichs-SKU und die SKU für öffentliche IP-Adressen übereinstimmen. In unserem Fall erstellen wir zwei öffentliche Standard-IP-Adressen: eine für den Lastenausgleich auf regionaler Ebene und eine für den globalen Lastenausgleich.

In der Vorlage wurden mehrere Azure-Ressourcen definiert:

Wichtig

Die Stundenpreise gelten ab dem Zeitpunkt der Bereitstellung von Bastion, unabhängig von der Nutzung ausgehender Daten. Weitere Informationen dazu finden Sie unter Preise und SKUs. Wenn Sie Bastion im Rahmen eines Tutorials oder Tests bereitstellen, empfiehlt es sich, diese Ressource zu löschen, nachdem Sie diese benutzt haben.

Weitere Vorlagen zum Azure Load Balancer finden Sie unter Azure-Schnellstartvorlagen.

Bereitstellen der Vorlage

  1. Melden Sie sich beim Azure-Portal an.

  2. Geben Sie in der Suchleiste Benutzerdefinierte Vorlage bereitstellen ein, und wählen Sie das entsprechende Ergebnis aus.

  3. Geben Sie auf der Seite Benutzerdefinierte Bereitstellung in das Textfeld Schnellstartvorlage den Text load-balancer-cross-region ein, und wählen Sie quickstarts/microsoft.network/load-balancer-cross-region aus.

    Screenshot: Seite „Benutzerdefinierte Bereitstellung“ zum Auswählen einer ARM-Schnellstartvorlage

  4. Wählen Sie Vorlage auswählen aus, und geben Sie die folgenden Informationen ein:

    Name Wert
    Abonnement Wählen Sie Ihr Abonnement aus.
    Ressourcengruppe Wählen Sie Ihre Ressourcengruppe aus, oder erstellen Sie eine neue Ressourcengruppe.
    Region Wählen Sie die Bereitstellungsregion für Ressourcen aus.
    Projektname Geben Sie einen Projektnamen ein, der zum Erstellen eindeutiger Ressourcennamen verwendet wird.
    LocationCR Wählen Sie die Bereitstellungsregion für den regionsübergreifenden Lastenausgleich aus.
    Location-r1 Wählen Sie die Bereitstellungsregion für den regionalen Lastenausgleich und VMs aus.
    Location-r2 Wählen Sie die Bereitstellungsregion für den regionalen Lastenausgleich und VMs aus.
    Administratorbenutzername Geben Sie einen Benutzernamen für die virtuellen Computer ein.
    Administratorkennwort Geben Sie ein Kennwort für die virtuellen Computer ein.
  5. Wählen Sie zum Ausführen der Vorlagenvalidierung Bewerten + erstellen aus.

  6. Wenn keine Fehler auftreten, überprüfen Sie die Bedingungen der Vorlage, und wählen Sie Erstellen aus.

Überprüfen der Bereitstellung

  1. Melden Sie sich ggf. beim Azure-Portal an.

  2. Wählen Sie im linken Bereich Ressourcengruppen aus.

  3. Wählen Sie die Ressourcengruppe aus, die in der Bereitstellung verwendet wird. Der Ressourcengruppenname entspricht standardmäßig dem Projektnamen mit dem Zusatz -rg. Beispiel: crlb-learn-arm-rg.

  4. Wählen Sie den globalen Lastenausgleich aus. Sein Standardname entspricht dem Projektnamen mit dem Zusatz -cr. Beispiel: crlb-learn-arm-cr.

  5. Kopieren Sie nur den IP-Adressteil der öffentlichen IP-Adresse, und fügen Sie ihn in die Adressleiste des Browsers ein. Die Seite wird in eine IIS-Standardwebseite für Windows Server aufgelöst.

    Screenshot: IIS-Standardwebseite für Windows Server im Webbrowser

Bereinigen von Ressourcen

Löschen Sie die Ressourcen, wenn Sie sie nicht mehr benötigen:

  • Ressourcengruppe
  • Load Balancer
  • Verwandte Ressourcen
  1. Wählen Sie im Azure-Portal die Ressourcengruppe aus, die den Lastenausgleich enthält, und wählen Sie anschließend Ressourcengruppe löschen aus.
  2. Wählen Sie Löschung ausgewählter VMs und VM-Skalierungsgruppen erzwingen aus, geben Sie den Namen der Ressourcengruppe ein, und wählen Sie dann **Löschen > Löschen** aus.

Nächste Schritte

In diesem Tutorial führen Sie Folgendes durch:

  • Erstellen eines regionsübergreifenden Lastenausgleichs
  • Erstellen eines regionalen Lastenausgleichs
  • Erstellen von drei virtuellen Computer und Verknüpfen mit dem regionalen Lastenausgleich
  • Konfigurieren des globalen Lastenausgleichs für die Verwendung mit dem regionalen Lastenausgleich
  • Testet den globalen Lastenausgleichsmodul.

Hier erfahren Sie mehr über den regionsübergreifenden Lastenausgleich.
Fahren Sie mit dem nächsten Artikel fort, um mehr über das Erstellen zu erfahren.