使用 Azure 门户将 Azure 公共 IP 移到另一个区域Move Azure Public IP to another region using the Azure portal

在多种情况下,你可能希望将现有的 Azure 公共 IP 从一个区域移到另一个区域。There are various scenarios in which you'd want to move your existing Azure Public IPs from one region to another. 例如,可能需要创建一个具有相同配置和 SKU 的公共 IP,以便进行测试。For example, you may want to create a public IP with the same configuration and sku for testing. 还可能需要按照灾难恢复规划将公共 IP 移到另一个区域。You may also want to move a public IP to another region as part of disaster recovery planning.

Azure 公共 IP 特定于区域,不能从一个区域移到另一个区域。Azure Public IPs are region specific and can't be moved from one region to another. 但是,可以使用 Azure 资源管理器模板来导出公共 IP 的现有配置。You can however, use an Azure Resource Manager template to export the existing configuration of a public IP. 然后,可以将资源暂存在另一区域,方法是:将公共 IP 导出到模板,根据目标区域的情况修改参数,然后将模板部署到新区域。You can then stage the resource in another region by exporting the public IP to a template, modifying the parameters to match the destination region, and then deploy the template 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 公共 IP 位于要从中移动的 Azure 区域中。Make sure that the Azure Public IP is in the Azure region from which you want to move.

  • Azure 公共 IP 无法在区域之间移动。Azure Public IPs can't be moved between regions. 必须将新的公共 IP 关联到目标区域中的资源。You'll have to associate the new public ip to resources in the target region.

  • 若要导出公共 IP 配置并部署模板,以便在另一区域创建公共 IP,需要“网络参与者”角色或更高级别的角色。To export a public IP configuration and deploy a template to create a public IP 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. 此布局包括但不限于负载均衡器、网络安全组 (NSG) 和虚拟网络。This layout includes but isn't limited to load balancers, network security groups (NSGs), and virtual networks.

  • 验证 Azure 订阅是否允许在已使用的目标区域中创建公共 IP。Verify that your Azure subscription allows you to create public IPs in the target region that's used. 请联系支持部门,启用所需配额。Contact support to enable the required quota.

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

准备并移动Prepare and move

以下步骤说明如何使用资源管理器模板准备公共 IP,以进行配置移动,并使用 Azure 门户将公共 IP 配置移到目标区域。The following steps show how to prepare the public IP for the configuration move using a Resource Manager template, and move the public IP configuration to the target region using the Azure portal.

通过脚本导出模板并进行部署Export the template and deploy from a script

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

  2. 找到包含源公共 IP 的资源组并单击它。Locate the Resource Group that contains the source public IP 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. 若要编辑公共 IP 名称的参数,请将源公共 IP 名称中 parameters > value 下的属性更改为目标公共 IP 的名称(请务必将名称括在引号中):To edit the parameter of the public IP name, change the property under parameters > value from the source public IP name to the name of your target public IP, ensure the name is in quotes:

    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "publicIPAddresses_myVM1pubIP_name": {
            "value": "<target-publicip-name>"
              }
         }
    }
    
    
  7. 在编辑器中单击“保存”。 Click Save in the editor.

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

  9. 若要编辑要将公共 IP 移到其中的目标区域,请更改 resources 下的 location 属性:To edit the target region where the public IP will be moved, change the location property under resources:

    "resources": [
        {
            "type": "Microsoft.Network/publicIPAddresses",
            "apiVersion": "2019-06-01",
            "name": "[parameters('publicIPAddresses_myPubIP_name')]",
            "location": "<target-region>",
            "sku": {
                "name": "Basic",
                "tier": "Regional"
            },
            "properties": {
                "provisioningState": "Succeeded",
                "resourceGuid": "7549a8f1-80c2-481a-a073-018f5b0b69be",
                "ipAddress": "52.177.6.204",
                "publicIPAddressVersion": "IPv4",
                "publicIPAllocationMethod": "Dynamic",
                "idleTimeoutInMinutes": 4,
                "ipTags": []
            }
        }
     ]
    
  10. 若要获取区域位置代码,请参阅 Azure 位置To obtain region location codes, see Azure Locations. 区域的代码是不带空格的区域名称,中国北部 = chinanorthThe code for a region is the region name with no spaces, China North = chinanorth.

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

    • SKU - 可以在配置中将公共 IP 的 SKU 从 standard 更改为 basic 或从 basic 更改为 standard,只需在 template.json 文件中更改 sku > name 属性即可:Sku - You can change the sku of the public IP 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/publicIPAddresses",
          "apiVersion": "2019-06-01",
          "name": "[parameters('publicIPAddresses_myPubIP_name')]",
          "location": "<target-region>",
          "sku": {
              "name": "Basic",
              "tier": "Regional"
          },
      

      若要详细了解基本的和标准的 sku 公共 IP 的区别,请参阅创建、更改或删除公共 IP 地址For more information on the differences between basic and standard sku public ips, see Create, change, or delete a public IP address:

    • 公共 IP 分配方法空闲超时 - 可以在模板中更改这两个选项,只需将 publicIPAllocationMethod 属性从 Dynamic 更改为 Static 或从 Static 更改为 Dynamic 即可。Public IP allocation method and Idle timeout - You can change both of these options in the template by altering the publicIPAllocationMethod property from Dynamic to Static or Static to Dynamic. 若要更改空闲超时,可以将 idleTimeoutInMinutes 属性更改为所需时间。The idle timeout can be changed by altering the idleTimeoutInMinutes property to your desired amount. 默认为 4The default is 4:

      "resources": [
          {
              "type": "Microsoft.Network/publicIPAddresses",
              "apiVersion": "2019-06-01",
              "name": "[parameters('publicIPAddresses_myPubIP_name')]",
              "location": "<target-region>",
              "sku": {
                  "name": "Basic",
                  "tier": "Regional"
              },
              "properties": {
                  "provisioningState": "Succeeded",
                  "resourceGuid": "7549a8f1-80c2-481a-a073-018f5b0b69be",
                  "ipAddress": "52.177.6.204",
                  "publicIPAddressVersion": "IPv4",
                  "publicIPAllocationMethod": "Dynamic",
                  "idleTimeoutInMinutes": 4,
                  "ipTags": []
      
      

      若要详细了解分配方法和空闲超时值,请参阅创建、更改或删除公共 IP 地址For more information on the allocation methods and the idle timeout values, see Create, change, or delete a public IP address.

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

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

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

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

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

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

  18. 单击“购买”按钮部署目标公共 IP。 Click the Purchase button to deploy the target public IP.

弃用Discard

若要丢弃目标公共 IP,请删除包含目标公共 IP 的资源组。If you wish to discard the target public IP, delete the resource group that contains the target public IP. 为此,请从门户上的仪表板中选择该资源组,然后选择概述页顶部的“删除”。 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

若要提交更改并完成公共 IP 的移动,请删除源公共 IP 或资源组。To commit the changes and complete the move of the public IP, delete the source public IP or resource group. 为此,请从门户上的仪表板中选择该公共 IP 或资源组,然后选择每个页面顶部的“删除”。 To do so, select the public IP or resource group from your dashboard in the portal and select Delete at the top of each page.

后续步骤Next steps

在本教程中,我们将 Azure 公共 IP 从一个区域移到了另一个区域,并清理了源资源。In this tutorial, you moved an Azure Public IP 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: