使用 Azure 门户将 Azure 虚拟网络移到另一个区域Move an Azure virtual network to another region by using the Azure portal

将现有 Azure 虚拟网络从一个区域移到另一个区域的方案有多种。There are various scenarios for moving an existing Azure virtual network from one region to another. 例如,可以创建一个与现有虚拟网络使用相同测试和可用性配置的虚拟网络。For example, you might want to create a virtual network with the same configuration for testing and availability as your existing virtual network. 或者,可以将生产虚拟网络移到另一个区域,作为灾难恢复计划的一部分。Or you might want to move a production virtual network to another region as part of your disaster recovery planning.

可以使用 Azure 资源管理器模板来完成将虚拟网络移到另一个区域的过程。You can use an Azure Resource Manager template to complete the move of the virtual network to another region. 为此,可将虚拟网络导出到某个模板,根据目标区域修改参数,然后将该模板部署到新区域。You do this by exporting the virtual network to a template, modifying the parameters to match the destination region, and then deploying the template to the new region. 有关资源管理器模板的详细信息,请参阅快速入门:使用 Azure 门户创建和部署 Azure 资源管理器模板For more information about Resource Manager templates, see Quickstart: Create and deploy Azure Resource Manager templates by using the Azure portal.

先决条件Prerequisites

  • 确保你的虚拟网络位于要从中进行移动的 Azure 区域中。Make sure that your virtual network is in the Azure region that you want to move from.

  • 若要导出虚拟网络并部署模板,以便在另一区域创建虚拟网络,需要“网络参与者”角色或更高级别的角色。To export a virtual network and deploy a template to create a virtual network in another region, you need to have the Network Contributor role or higher.

  • 不会重新创建虚拟网络对等互连,如果它们仍存在于模板中,它们将会失败。Virtual network peerings won't be re-created, and they'll fail if they're still present in the template. 在导出模板之前,必须删除所有虚拟网络对等互连。Before you export the template, you have to remove any virtual network peers. 然后,可以在移动虚拟网络后重新建立对等互连。You can then reestablish them after the virtual network move.

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

  • 验证 Azure 订阅是否允许在目标区域中创建虚拟网络。Verify that your Azure subscription allows you to create virtual networks in the target region. 若要启用所需配额,请联系支持部门。To enable the required quota, contact support.

  • 确保订阅提供足够的资源,以支持在此过程中添加虚拟网络。Make sure that your subscription has enough resources to support the addition of virtual networks for this process. 有关详细信息,请参阅 Azure 订阅和服务限制、配额与约束For more information, see Azure subscription and service limits, quotas, and constraints.

准备移动Prepare for the move

在本部分,你将使用资源管理器模板来准备好要移动的虚拟网络。In this section, you prepare the virtual network for the move by using a Resource Manager template. 然后,使用 Azure 门户将虚拟网络移到目标区域。You then move the virtual network to the target region by using the Azure portal.

若要使用 Azure 门户导出虚拟网络并部署目标虚拟网络,请执行以下操作:To export the virtual network and deploy the target virtual network by using the Azure portal, do the following:

  1. 登录到 Azure 门户,然后选择“资源组”。 Sign in to the Azure portal, and then select Resource Groups.

  2. 找到包含源虚拟网络的资源组并选择它。Locate the resource group that contains the source virtual network, and then select it.

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

  4. 在“导出模板”窗格中选择“部署”。 In the Export template pane, select Deploy.

  5. 若要在在线编辑器中打开 parameters.json 文件,请选择“模板” > “编辑参数”。 To open the parameters.json file in your online editor, select Template > Edit parameters.

  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. 在编辑器中,将源虚拟网络名称值更改为所需的目标虚拟网络名称。In the editor, change the source virtual network name value in the editor to a name that you want for the target virtual network. 请务必将名称括在引号中。Be sure to enclose the name in quotation marks.

  8. 在编辑器中选择“保存”。 Select Save in the editor.

  9. 若要在在线编辑器中打开 template.json 文件,请选择“模板” > “编辑模板”。 To open the template.json file in the online editor, select Template > Edit template.

  10. 在在线编辑器中,若要编辑要将虚拟网络移到的目标区域,请更改 resources 下的 location 属性:In the online editor, to edit the target region where the virtual network 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. 区域的代码是不带空格的区域名称(例如,中国北部 = chinanorth)。The code for a region is the region name, without spaces (for example, China North = chinanorth).

  12. (可选)还可以根据要求更改模板中的其他参数:(Optional) You can also change other parameters in the template, depending on your requirements:

    • 地址空间:在保存该文件之前,可以更改虚拟网络的地址空间,方法是修改 resources > addressSpace 节并更改 addressPrefixes 属性:Address Space: Before you save the file, you can alter the address space of the virtual network by modifying the resources > addressSpace section and changing the addressPrefixes property:

      "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"
                  ]
              },
      
      
    • 子网:可以通过更改该模板的 subnets 节来更改子网名称和子网地址空间或在其中添加内容。Subnet: You can change or add to the subnet name and the subnet address space by changing the template's subnets section. 可以通过更改 name 属性来更改子网名称。You can change the name of the subnet by changing the name property. 可以通过更改 addressPrefix 属性来更改子网地址空间:And you can change the subnet address space by changing the addressPrefix property:

      "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 节。To change the address prefix in the template.json file, edit it in two places: in the code in the preceding section and in the type section of the following code. 更改以下代码中的 addressPrefix 属性,使之与前一节的代码中的 addressPrefix 属性相匹配。Change the addressPrefix property in the following code to match the addressPrefix property in the code in the preceding section.

      {
          "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. 在在线编辑器中选择“保存”。 In the online editor, select Save.

  14. 若要选择要将目标虚拟网络部署到的订阅,请选择“基本信息” > “订阅”。 To choose the subscription where the target virtual network will be deployed, select Basics > Subscription.

  15. 若要选择要将目标虚拟网络部署到的资源组,请选择“基本信息” > “资源组”。 To choose the resource group where the target virtual network will be deployed, select Basics > Resource group.

    如果需要为目标虚拟网络创建新的资源组,请选择“新建”。 If you need to create a new resource group for the target virtual network, select Create new. 确保该名称不同于现有虚拟网络中的源资源组名称。Make sure that the name isn't the same as the source resource group name in the existing virtual network.

  16. 确认“基本信息” > “位置”是否设置为要将虚拟网络部署到的目标位置。 Verify that Basics > Location is set to the target location where you want the virtual network to be deployed.

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

  18. 选中“条款和条件”复选框。 Select the Terms and Conditions check box.

  19. 若要部署目标虚拟网络,请选择“购买”。 To deploy the target virtual network, select Purchase.

删除目标虚拟网络Delete the target virtual network

若要丢弃目标虚拟网络,请删除包含目标虚拟网络的资源组。To discard the target virtual network, you delete the resource group that contains the target virtual network. 为此,请执行以下操作:To do so:

  1. 在 Azure 门户仪表板上,选择该资源组。On the Azure portal dashboard, select the resource group.
  2. 在“概述”窗格的顶部,选择“删除”。 At the top of the Overview pane, select Delete.

清理Clean up

若要提交更改并完成虚拟网络的移动,请删除源虚拟网络或资源组。To commit the changes and complete the virtual network move, you delete the source virtual network or resource group. 为此,请执行以下操作:To do so:

  1. 在 Azure 门户仪表板上,选择该虚拟网络或资源组。On the Azure portal dashboard, select the virtual network or resource group.
  2. 在每个窗格的顶部,选择“删除”。 At the top of each pane, select Delete.

后续步骤Next steps

在本教程中,你已使用 Azure 门户将 Azure 虚拟网络从一个区域移到了另一个区域,然后清理了不再需要的源资源。In this tutorial, you moved an Azure virtual network from one region to another by using the Azure portal and then cleaned up the unneeded source resources. 若要详细了解如何在区域之间移动资源,以及如何在 Azure 中进行灾难恢复,请参阅:To learn more about moving resources between regions and disaster recovery in Azure, see: