使用 Azure 门户将 Azure 内部负载均衡器移到另一个区域Move Azure internal Load Balancer to another region using the Azure portal

在多种情况下,可能需要将现有的内部负载均衡器从一个区域移到另一个区域。There are various scenarios in which you'd want to move your existing internal load balancer from one region to another. 例如,你可能想要创建另一个采用相同配置的内部负载均衡器进行测试。For example, you may want to create an internal load balancer with the same configuration for testing. 你还可能想要在灾难恢复规划过程中将内部负载均衡器移到另一个区域。You may also want to move an internal load balancer to another region as part of disaster recovery planning.

无法将 Azure 内部负载均衡器从一个区域移到另一个区域。Azure internal load balancers can't be moved from one region to another. 但是,可以使用 Azure 资源管理器模板导出内部负载均衡器的现有配置和虚拟网络。You can however, use an Azure Resource Manager template to export the existing configuration and virtual network of an internal load balancer. 然后,可将资源暂存在另一区域,方法是:将负载均衡器和虚拟网络导出到某个模板,根据目标区域修改参数,然后将该模板部署到新区域。You can then stage the resource in another region by exporting the load balancer and virtual network to a template, modifying the parameters to match the destination region, and then deploy the templates to the new region. 有关资源管理器和模板的详细信息,请参阅快速入门:使用 Azure 门户创建和部署 Azure 资源管理器模板For more information on Resource Manager and templates, see Quickstart: Create and deploy Azure Resource Manager templates by using the Azure portal.

先决条件Prerequisites

  • 确保 Azure 内部负载均衡器位于要从中移动的 Azure 区域。Make sure that the Azure internal load balancer is in the Azure region from which you want to move.

  • 无法在区域之间移动 Azure 内部负载均衡器。Azure internal load balancers can't be moved between regions. 必须将新的负载均衡器关联到目标区域中的资源。You'll have to associate the new load balancer to resources in the target region.

  • 若要导出内部负载均衡器配置并部署模板,以便在另一区域创建外部负载均衡器,需有“网络参与者”角色或更高级别的角色。To export an internal load balancer configuration and deploy a template to create an internal load balancer in another region, you'll need the Network Contributor role or higher.

  • 确定源网络布局和当前正在使用的所有资源。Identify the source networking layout and all the resources that you're currently using. 此布局包括但不限于负载均衡器、网络安全组、虚拟机和虚拟网络。This layout includes but isn't limited to load balancers, network security groups, virtual machines, and virtual networks.

  • 请验证 Azure 订阅是否允许在所用的目标区域中创建内部负载均衡器。Verify that your Azure subscription allows you to create internal load balancers in the target region that's used. 请联系支持部门,启用所需配额。Contact support to enable the required quota.

  • 确保订阅提供足够的资源,以便为此过程添加公共负载均衡器。Make sure that your subscription has enough resources to support the addition of load balancers for this process. 请参阅 Azure 订阅和服务限制、配额和约束See Azure subscription and service limits, quotas, and constraints

准备并移动Prepare and move

以下步骤说明如何使用资源管理器模板准备好要移动的内部负载均衡器,并使用 Azure 门户将内部负载均衡器配置移到目标区域。The following steps show how to prepare the internal load balancer for the move using a Resource Manager template, and move the internal load balancer configuration to the target region using the Azure portal. 在此过程中,必须包括内部负载均衡器的虚拟网络配置,并且必须在移动内部负载均衡器之前完成此配置。As part of this process, the virtual network configuration of the internal load balancer must be included and must be done first before moving the internal load balancer.

备注

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

从 Azure 门户导出虚拟网络模板并进行部署Export the virtual network template and deploy from the Azure portal

  1. 登录到 Azure 门户 > 选择“资源组”。 Login to the Azure portal > Resource Groups.

  2. 找到包含源虚拟网络的资源组并单击它。Locate the Resource Group that contains the source virtual network and click on it.

  3. 选择“设置” > “导出模板”。 Select > Settings > Export template.

  4. 在“导出模板”边栏选项卡中选择“部署”。 Choose Deploy in the Export template blade.

  5. 单击“模板” > “编辑参数”,在在线编辑器中打开 parameters.json 文件。 Click TEMPLATE > Edit parameters to open the parameters.json file in the online editor.

  6. 若要编辑虚拟网络名称的参数,请更改 parameters 下的 value 属性:To edit the parameter of the virtual network name, change the value property under parameters:

    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "virtualNetworks_myVNET1_name": {
                "value": "<target-virtual-network-name>"
            }
        }
    }
    
  7. 将编辑器中的源虚拟网络名称值更改为目标 VNET 的所选名称。Change the source virtual network name value in the editor to a name of your choice for the target VNET. 请务必将名称括在引号中。Ensure you enclose the name in quotes.

  8. 在编辑器中单击“保存”。 Click Save in the editor.

  9. 单击“模板” > “编辑模板”,在在线编辑器中打开 template.json 文件。 Click TEMPLATE > Edit template to open the template.json file in the online editor.

  10. 若要编辑要将 VNET 移到的目标区域,请更改 resources 下的 location 属性:To edit the target region where the VNET will be moved, change the location property under resources:

    "resources": [
                {
                    "type": "Microsoft.Network/virtualNetworks",
                    "apiVersion": "2019-06-01",
                    "name": "[parameters('virtualNetworks_myVNET1_name')]",
                    "location": "<target-region>",
                    "properties": {
                        "provisioningState": "Succeeded",
                        "resourceGuid": "6e2652be-35ac-4e68-8c70-621b9ec87dcb",
                        "addressSpace": {
                            "addressPrefixes": [
                                "10.0.0.0/16"
                            ]
                        },
    
    
  11. 若要获取区域位置代码,请参阅 Azure 位置To obtain region location codes, see Azure Locations. 区域的代码是不带空格的区域名称,中国东部 2 = chinaeast2The code for a region is the region name with no spaces, China East 2 = chinaeast2.

  12. 还可以选择更改 template.json 中的其他参数,这些参数是可选的,具体取决于你的要求:You can also change other parameters in the template.json file if you choose, and are optional depending on your requirements:

    • 地址空间 - 在保存之前,可以通过在 template.json 文件中修改 resources > addressSpace 节并更改 addressPrefixes 属性,来更改 VNET 的地址空间:Address Space - The address space of the VNET can be altered before saving by modifying the resources > addressSpace section and changing the addressPrefixes property in the template.json file:

              "resources": [
                  {
                  "type": "Microsoft.Network/virtualNetworks",
                  "apiVersion": "2019-06-01",
                  "name": "[parameters('virtualNetworks_myVNET1_name')]",
                  "location": "<target-region",
                  "properties": {
                  "provisioningState": "Succeeded",
                  "resourceGuid": "6e2652be-35ac-4e68-8c70-621b9ec87dcb",
                  "addressSpace": {
                      "addressPrefixes": [
                      "10.0.0.0/16"
                      ]
                  },
      
      
    • 子网 - 可以通过修改 template.json 文件的 subnets 节来更改子网名称和子网地址空间。Subnet - The subnet name and the subnet address space can be changed or added to by modifying the subnets section of the template.json file. 可以通过更改 name 属性来更改子网的名称。The name of the subnet can be changed by altering the name property. 可以通过更改 template.json 文件中的 addressPrefix 属性来更改子网地址空间:The subnet address space can be changed by altering the addressPrefix property in the template.json file:

              "subnets": [
                  {
                  "name": "subnet-1",
                  "etag": "W/\"d9f6e6d6-2c15-4f7c-b01f-bed40f748dea\"",
                  "properties": {
                  "provisioningState": "Succeeded",
                  "addressPrefix": "10.0.0.0/24",
                  "delegations": [],
                  "privateEndpointNetworkPolicies": "Enabled",
                  "privateLinkServiceNetworkPolicies": "Enabled"
                  }
                  },
                  {
                  "name": "GatewaySubnet",
                  "etag": "W/\"d9f6e6d6-2c15-4f7c-b01f-bed40f748dea\"",
                  "properties": {
                  "provisioningState": "Succeeded",
                  "addressPrefix": "10.0.1.0/29",
                  "serviceEndpoints": [],
                  "delegations": [],
                  "privateEndpointNetworkPolicies": "Enabled",
                  "privateLinkServiceNetworkPolicies": "Enabled"
                  }
                  }
      
              ]
      

      若要在 template.json 文件中更改地址前缀,必须在两处进行编辑:上面列出的节,以及下面列出的 type 节。In the template.json file, to change the address prefix, it must be edited in two places, the section listed above and the type section listed below. addressPrefix 属性更改为与上述某个节相匹配:Change the addressPrefix property to match the one above:

       "type": "Microsoft.Network/virtualNetworks/subnets",
         "apiVersion": "2019-06-01",
         "name": "[concat(parameters('virtualNetworks_myVNET1_name'), '/GatewaySubnet')]",
            "dependsOn": [
               "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworks_myVNET1_name'))]"
                 ],
            "properties": {
               "provisioningState": "Succeeded",
               "addressPrefix": "10.0.1.0/29",
               "serviceEndpoints": [],
               "delegations": [],
               "privateEndpointNetworkPolicies": "Enabled",
               "privateLinkServiceNetworkPolicies": "Enabled"
                }
               },
                {
                "type": "Microsoft.Network/virtualNetworks/subnets",
                "apiVersion": "2019-06-01",
                "name": "[concat(parameters('virtualNetworks_myVNET1_name'), '/subnet-1')]",
                   "dependsOn": [
                      "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworks_myVNET1_name'))]"
                        ],
                   "properties": {
                      "provisioningState": "Succeeded",
                      "addressPrefix": "10.0.0.0/24",
                      "delegations": [],
                      "privateEndpointNetworkPolicies": "Enabled",
                      "privateLinkServiceNetworkPolicies": "Enabled"
                       }
                }
       ]
      
  13. 在在线编辑器中单击“保存”。 Click Save in the online editor.

  14. 单击“基本信息” > “订阅”,以选择要将目标 VNET 部署到的订阅。 Click BASICS > Subscription to choose the subscription where the target VNET will be deployed.

  15. 单击“基本信息” > “资源组”,以选择要将目标 VNET 部署到的资源组。 Click BASICS > Resource group to choose the resource group where the target VNET will be deployed. 可以单击“新建”来为目标 VNET 创建新的资源组。 You can click Create new to create a new resource group for the target VNET. 确保该名称不同于现有 VNET 的源资源组名称。Ensure the name is not the same as the source resource group of the existing VNET.

  16. 确认“基本信息” > “位置”是否设置为要将 VNET 部署到的目标位置。 Verify BASICS > Location is set to the target location where you wish for the VNET to be deployed.

  17. 在“设置”下,确认名称是否与先前在 parameters 编辑器中输入的名称相匹配。 Verify under SETTINGS that the name matches the name that you entered in the parameters editor above.

  18. 选中“条款和条件”下的框。 Check the box under TERMS AND CONDITIONS.

  19. 单击“购买”按钮部署目标虚拟网络。 Click the Purchase button to deploy the target virtual network.

从 Azure PowerShell 导出内部负载均衡器模板并进行部署Export the internal load balancer template and deploy from Azure PowerShell

  1. 登录到 Azure 门户 > 选择“资源组”。 Login to the Azure portal > Resource Groups.

  2. 找到包含源内部负载均衡器的资源组并单击它。Locate the Resource Group that contains the source internal load balancer and click on it.

  3. 选择“设置” > “导出模板”。 Select > Settings > Export template.

  4. 在“导出模板”边栏选项卡中选择“部署”。 Choose Deploy in the Export template blade.

  5. 单击“模板” > “编辑参数”,在在线编辑器中打开 parameters.json 文件。 Click TEMPLATE > Edit parameters to open the parameters.json file in the online editor.

  6. 若要编辑内部负载均衡器名称的参数,请将源内部负载均衡器名称的属性 defaultValue 更改为目标内部负载均衡器的名称(请务必将名称括在引号中):To edit the parameter of the internal load balancer name, change the property defaultValue of the source internal load balancer name to the name of your target internal load balancer, ensure the name is in quotes:

         "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
         "contentVersion": "1.0.0.0",
         "parameters": {
            "loadBalancers_myLoadBalancer_name": {
            "defaultValue": "<target-internal-lb-name>",
            "type": "String"
             },
            "virtualNetworks_myVNET2_internalid": {
             "defaultValue": "<target-vnet-resource-ID>",
             "type": "String"
             }
    
  7. 若要编辑上面已移动的目标虚拟网络的值,必须先获取资源 ID,然后将其复制并粘贴到 parameters.json 文件中。To edit value of the target virtual network that was moved above, you must first obtain the resource ID and then copy and paste it into the parameters.json file. 若要获取 ID:To obtain the ID:

    1. 在另一个浏览器标签页或窗口中登录到 Azure 门户 > 选择“资源组”。 Login to the Azure portal > Resource Groups in another browser tab or window.

    2. 找到通过上述步骤移动的虚拟网络所在的目标资源组,并单击它。Locate the target resource group that contains the moved virtual network from the steps above, and click on it.

    3. 选择“设置” > “属性”。 Select > Settings > Properties.

    4. 在右侧的边栏选项卡中,突出显示“资源 ID”并将其复制到剪贴板。 In the blade to the right, highlight the Resource ID and copy it to the clipboard. 或者,可以单击“资源 ID”路径右侧的“复制到剪贴板”按钮。 Alternatively, you can click on the copy to clipboard button to the right of the Resource ID path.

    5. 将资源 ID 粘贴到在另一个浏览器窗口或标签页中打开的“编辑参数”编辑器中的 defaultValue 属性: Paste the resource ID into the defaultValue property into the Edit Parameters editor open in the other browser window or tab:

       "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
       "contentVersion": "1.0.0.0",
       "parameters": {
          "loadBalancers_myLoadBalancer_name": {
          "defaultValue": "<target-internal-lb-name>",
          "type": "String"
           },
          "virtualNetworks_myVNET2_internalid": {
           "defaultValue": "<target-vnet-resource-ID>",
           "type": "String"
           }
      
    6. 在在线编辑器中单击“保存”。 Click Save in the online editor.

  8. 单击“模板” > “编辑模板”,在在线编辑器中打开 template.json 文件。 Click TEMPLATE > Edit template to open the template.json file in the online editor.

  9. 若要编辑内部负载均衡器配置将要移到的目标区域,请更改 template.json 文件中 resources 下的 location 属性:To edit the target region where the internal load balancer configuration will be moved, change the location property under resources in the template.json file:

        "resources": [
            {
                "type": "Microsoft.Network/loadBalancers",
                "apiVersion": "2019-06-01",
                "name": "[parameters('loadBalancers_myLoadBalancer_name')]",
                "location": "<target-internal-lb-region>",
                "sku": {
                    "name": "Standard",
                    "tier": "Regional"
                },
    
  10. 若要获取区域位置代码,请参阅 Azure 位置To obtain region location codes, see Azure Locations. 区域的代码是不带空格的区域名称,中国东部 2 = chinaeast2The code for a region is the region name with no spaces, China East 2 = chinaeast2.

  11. 也可选择更改模板中的其他参数,这些参数是可选的,具体取决于你的要求:You can also change other parameters in the template if you choose, and are optional depending on your requirements:

    • SKU - 可以在配置中将内部负载均衡器的 SKU 从 standard 更改为 basic 或者从 basic 更改为 standard,只需在 template.json 文件中更改 sku > name 属性即可:Sku - You can change the sku of the internal load balancer in the configuration from standard to basic or basic to standard by altering the sku > name property in the template.json file:

      "resources": [
      {
          "type": "Microsoft.Network/loadBalancers",
          "apiVersion": "2019-06-01",
          "name": "[parameters('loadBalancers_myLoadBalancer_name')]",
          "location": "<target-internal-lb-region>",
          "sku": {
              "name": "Standard",
              "tier": "Regional"
          },
      

      若要详细了解基本和标准 sku 负载均衡器之间的区别,请参阅 Azure 标准负载均衡器概述For more information on the differences between basic and standard sku load balancers, see Azure Standard Load Balancer overview

    • 负载均衡规则 - 可以通过在 template.json 文件的 loadBalancingRules 节中添加或删除条目,在配置中添加或删除负载均衡规则:Load balancing rules - You can add or remove load balancing rules in the configuration by adding or removing entries to the loadBalancingRules section of the template.json file:

      "loadBalancingRules": [
                  {
                      "name": "myInboundRule",
                      "etag": "W/\"39e5e9cd-2d6d-491f-83cf-b37a259d86b6\"",
                      "properties": {
                          "provisioningState": "Succeeded",
                          "frontendIPConfiguration": {
                              "id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLoadBalancer_name')), '/frontendIPConfigurations/myfrontendIPinbound')]"
                          },
                          "frontendPort": 80,
                          "backendPort": 80,
                          "enableFloatingIP": false,
                          "idleTimeoutInMinutes": 4,
                          "protocol": "Tcp",
                          "enableTcpReset": false,
                          "loadDistribution": "Default",
                          "disableOutboundSnat": true,
                          "backendAddressPool": {
                              "id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLoadBalancer_name')), '/backendAddressPools/myBEPoolInbound')]"
                          },
                          "probe": {
                              "id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLoadBalancer_name')), '/probes/myHTTPProbe')]"
                          }
                      }
                  }
              ]
      

      有关负载均衡规则的详细信息,请参阅什么是 Azure 负载均衡器?For more information on load balancing rules, see What is Azure Load Balancer?

    • 探测 - 可以通过在 template.json 文件的 probes 节中添加或删除条目,在配置中添加或删除负载均衡器的探测:Probes - You can add or remove a probe for the load balancer in the configuration by adding or removing entries to the probes section of the template.json file:

      "probes": [
                  {
                      "name": "myHTTPProbe",
                      "etag": "W/\"39e5e9cd-2d6d-491f-83cf-b37a259d86b6\"",
                      "properties": {
                          "provisioningState": "Succeeded",
                          "protocol": "Http",
                          "port": 80,
                          "requestPath": "/",
                          "intervalInSeconds": 15,
                          "numberOfProbes": 2
                      }
                  }
              ],
      

      有关 Azure 负载均衡器运行状况探测的详细信息,请参阅负载均衡器运行状况探测For more information on Azure Load Balancer health probes, see Load Balancer health probes

    • 入站 NAT 规则 - 可以通过在 template.json 文件的 inboundNatRules 节中添加或删除条目,来添加或删除负载均衡器的入站 NAT 规则:Inbound NAT rules - You can add or remove inbound NAT rules for the load balancer by adding or removing entries to the inboundNatRules section of the template.json file:

      "inboundNatRules": [
                  {
                      "name": "myInboundNATRule",
                      "etag": "W/\"39e5e9cd-2d6d-491f-83cf-b37a259d86b6\"",
                      "properties": {
                          "provisioningState": "Succeeded",
                          "frontendIPConfiguration": {
                              "id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLoadBalancer_name')), '/frontendIPConfigurations/myfrontendIPinbound')]"
                          },
                          "frontendPort": 4422,
                          "backendPort": 3389,
                          "enableFloatingIP": false,
                          "idleTimeoutInMinutes": 4,
                          "protocol": "Tcp",
                          "enableTcpReset": false
                      }
                  }
              ]
      

      若要完成某个入站 NAT 规则的添加或删除,该规则必须作为 type 属性出现在 template.json 文件的末尾,或者已被删除:To complete the addition or removal of an inbound NAT rule, the rule must be present or removed as a type property at the end of the template.json file:

      {
          "type": "Microsoft.Network/loadBalancers/inboundNatRules",
          "apiVersion": "2019-06-01",
          "name": "[concat(parameters('loadBalancers_myLoadBalancer_name'), '/myInboundNATRule')]",
          "dependsOn": [
              "[resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLoadBalancer_name'))]"
          ],
          "properties": {
              "provisioningState": "Succeeded",
              "frontendIPConfiguration": {
                  "id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLoadBalancer_name')), '/frontendIPConfigurations/myfrontendIPinbound')]"
              },
              "frontendPort": 4422,
              "backendPort": 3389,
              "enableFloatingIP": false,
              "idleTimeoutInMinutes": 4,
              "protocol": "Tcp",
              "enableTcpReset": false
          }
      }
      

      有关入站 NAT 规则的详细信息,请参阅什么是 Azure 负载均衡器?For more information on inbound NAT rules, see What is Azure Load Balancer?

  12. 在在线编辑器中单击“保存”。 Click Save in the online editor.

  13. 单击“基本信息” > “订阅”,以选择要将目标内部负载均衡器部署到的订阅。 Click BASICS > Subscription to choose the subscription where the target internal load balancer will be deployed.

  14. 单击“基本信息” > “资源组”,以选择要将目标负载均衡器部署到的资源组。 Click BASICS > Resource group to choose the resource group where the target load balancer will be deployed. 可以单击“新建”来为目标内部负载均衡器创建新资源组,或选择前面为虚拟网络创建的现有资源组。 You can click Create new to create a new resource group for the target internal load balancer or choose the existing resource group that was created above for the virtual network. 请确保所选名称与现有源内部负载均衡器的源资源组不同。Ensure the name isn't the same as the source resource group of the existing source internal load balancer.

  15. 确认“基本信息” > “位置”是否设置为要将内部负载均衡器部署到的目标位置。 Verify BASICS > Location is set to the target location where you wish for the internal load balancer to be deployed.

  16. 在“设置”下,确认名称是否与先前在 parameters 编辑器中输入的名称相匹配。 Verify under SETTINGS that the name matches the name that you entered in the parameters editor above. 确认是否为配置中的所有虚拟网络填充了资源 ID。Verify the resource IDs are populated for any virtual networks in the configuration.

  17. 选中“条款和条件”下的框。 Check the box under TERMS AND CONDITIONS.

  18. 单击“购买”按钮部署目标虚拟网络。 Click the Purchase button to deploy the target virtual network.

弃用Discard

若要丢弃目标虚拟网络和内部负载均衡器,请删除包含目标虚拟网络和内部负载均衡器的资源组。If you wish to discard the target virtual network and internal load balancer, delete the resource group that contains the target virtual network and internal load balancer. 为此,请从门户上的仪表板中选择该资源组,然后选择概述页顶部的“删除”。 To do so, select the resource group from your dashboard in the portal and select Delete at the top of the overview page.

清理Clean up

若要提交更改并完成虚拟网络和内部负载均衡器的移动操作,请删除源虚拟网络和内部负载均衡器或资源组。To commit the changes and complete the move of the virtual network and internal load balancer, delete the source virtual network and internal load balancer or resource group. 为此,请在门户上的仪表板中选择该虚拟网络和内部负载均衡器或资源组,然后选择每个页面顶部的“删除”。 To do so, select the virtual network and internal load balancer or resource group from your dashboard in the portal and select Delete at the top of each page.

后续步骤Next steps

在本教程中,你已将一个 Azure 内部负载均衡器从一个区域移到了另一个区域,并清理了源资源。In this tutorial, you moved an Azure internal load balancer from one region to another and cleaned up the source resources. 若要详细了解如何在区域之间移动资源,以及如何在 Azure 中进行灾难恢复,请参阅:To learn more about moving resources between regions and disaster recovery in Azure, refer to: