您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

升级 Azure 公共负载均衡器Upgrade Azure Public Load Balancer

Azure 标准负载均衡器通过区域冗余提供丰富的功能和高可用性。Azure Standard Load Balancer offers a rich set of functionality and high availability through zone redundancy. 有关负载均衡器 SKU 的详细信息,请参阅比较表To learn more about Load Balancer SKU, see comparison table.

升级分为两个阶段:There are two stages in an upgrade:

  1. 将 IP 分配方法由动态更改为静态。Change IP allocation method from Dynamic to Static.
  2. 运行 PowerShell 脚本以完成升级和流量迁移。Run the PowerShell script to complete the upgrade and traffic migration.

重要

该脚本目前正在维护中。The script is currently under maintenance. 有关如何从基本 SKU 和标准 SKU 升级公共 IP 地址的说明,请参阅此处的说明。You can refer to instructions here on how to upgrade Public IP addresses from Basic SKU and Standard SKU.

升级概述Upgrade overview

我们提供了一个用于执行以下操作的 Azure PowerShell 脚本:An Azure PowerShell script is available that does the following:

  • 使用在基本标准负载均衡器的同一资源组中指定的位置创建标准 SKU 负载均衡器。Creates a Standard SKU Load Balancer with location you specify in the same resource group of the Basic Standard Load Balancer.
  • 将公共 IP 地址从基本 SKU 就地升级到标准 SKU。Upgrades Public IP address from Basic SKU to Standard SKU in-place.
  • 将基本 SKU 负载均衡器的配置无缝复制到新建的标准负载均衡器。Seamlessly copies the configurations of the Basic SKU Load Balancer to the newly create Standard Load Balancer.
  • 创建允许出站连接的默认出站规则。Creates a default outbound rule which enables outbound connectivity.

注意事项/限制Caveats\Limitations

  • 脚本仅支持公共负载均衡器升级。Script only supports Public Load Balancer upgrade. 若要进行内部基本负载均衡器升级,请参阅此页以获取说明。For Internal Basic Load Balancer upgrade, refer to this page for instructions.
  • 在运行脚本之前,必须将公共 IP 地址的分配方法更改为“静态”。The allocation method of the Public IP Address has to be changed to "static" before running the script.
  • 如果负载均衡器没有任何前端 IP 配置或后端池,则运行脚本时可能会遇到错误。If your Load Balancer does not have any frontend IP configuration or backend pool, you are likely to hit an error running the script. 请确保负载均衡器不是空的。Please make sure they are not empty.

将公共 IP 地址的分配方法更改为“静态”Change Allocation method of the Public IP Address to Static

  • **下面是我们的建议步骤:**Here are our recommended steps:

    1. 若要执行本快速入门中的任务,请登录 Azure 门户To do the tasks in this quickstart, sign in to the Azure portal.

    2. 在左侧菜单中选择“所有资源”,然后从资源列表中选择“与基本负载均衡器关联的基本公共 IP 地址” 。Select All resources on the left menu, and then select the Basic Public IP Address associated with Basic Load Balancer from the resource list.

    3. 在“设置”下,选择“配置” 。Under Settings, select Configurations.

    4. 在“分配”下,选择“静态”。Under Assignment, select Static.

    5. 选择“保存” 。Select Save.

    备注

    对于使用公共 IP 的 VM,在不保证 IP 地址相同的情况下,需要先创建标准 IP 地址。For VMs which have Public IPs, you will need to create Standard IP addresses first where same IP address is not guaranteed. 将 VM 与基本 IP 取消关联,并将 VM 关联到新建的标准 IP 地址。Disassociate VMs from Basic IPs and associate them with the newly created Standard IP addresses. 然后,即可按照说明将 VM 添加到标准负载均衡器的后端池。Then, you will be able to follow instructions to add VMs into backend pool of Standard Load Balancer.

  • 创建要添加到新建标准公共负载均衡器的后端池的新 VMCreating new VMs to add to the backend pools of the newly created Standard Public Load Balancer.

    • 此处可以找到有关如何创建 VM 并将关联到标准负载均衡器的详细说明。More instructions on how to create VM and associate it with Standard Load Balancer can be found here.

下载脚本Download the script

PowerShell 库下载迁移脚本。Download the migration script from the PowerShell Gallery.

使用脚本Use the script

根据本地 PowerShell 环境的设置和首选项,可以使用两个选项:There are two options for you depending on your local PowerShell environment setup and preferences:

  • 如果你尚未安装 Azure Az 模块或者不介意卸载 Azure Az 模块,最佳做法是使用 Install-Script 选项运行该脚本。If you don’t have the Azure Az modules installed, or don’t mind uninstalling the Azure Az modules, the best option is to use the Install-Script option to run the script.
  • 如果需要保留 Azure Az 模块,则最佳做法是下载并直接运行该脚本。If you need to keep the Azure Az modules, your best bet is to download the script and run it directly.

若要确定是否安装了 Azure Az 模块,请运行 Get-InstalledModule -Name azTo determine if you have the Azure Az modules installed, run Get-InstalledModule -Name az. 如果未看到任何已安装的 Az 模块,可以使用 Install-Script 方法。If you don't see any installed Az modules, then you can use the Install-Script method.

使用 Install-Script 方法安装Install using the Install-Script method

只有尚未在计算机上安装 Azure Az 模块时才能使用此选项。To use this option, you must not have the Azure Az modules installed on your computer. 如果已安装,则以下命令将显示错误。If they're installed, the following command displays an error. 可以卸载 Azure Az 模块,或者另一个选项手动下载并运行该脚本。You can either uninstall the Azure Az modules, or use the other option to download the script manually and run it.

使用以下命令运行该脚本:Run the script with the following command:

Install-Script -Name AzurePublicLBUpgrade

此命令还会安装所需的 Az 模块。This command also installs the required Az modules.

直接使用脚本安装Install using the script directly

如果已安装某些 Azure Az 模块并且无法卸载它们(或者不想卸载),可以使用脚本下载链接中的“手动下载”选项卡手动下载该脚本。If you do have some Azure Az modules installed and can't uninstall them (or don't want to uninstall them), you can manually download the script using the Manual Download tab in the script download link. 此脚本将作为原始 nupkg 文件下载。The script is downloaded as a raw nupkg file. 若要安装此 nupkg 文件中的脚本,请参阅手动下载包To install the script from this nupkg file, see Manual Package Download.

若要运行该脚本,请执行以下操作:To run the script:

  1. 使用 Connect-AzAccount 连接到 Azure。Use Connect-AzAccount to connect to Azure.

  2. 使用 Import-Module Az 导入 Az 模块。Use Import-Module Az to import the Az modules.

  3. 检查所需的参数:Examine the required parameters:

    • oldRgName: [String]:必需 – 这是要升级的现有基本负载均衡器的资源组。oldRgName: [String]: Required – This is the resource group for your existing Basic Load Balancer you want to upgrade. 若要查找此字符串值,请导航到 Azure 门户,选择你的基本负载均衡器源,然后单击该负载均衡器的“概览”。To find this string value, navigate to Azure portal, select your Basic Load Balancer source, and click the Overview for the load balancer. 资源组位于该页上。The Resource Group is located on that page.
    • oldLBName: [String]:必需 – 这是要升级的现有基本负载均衡器的名称。oldLBName: [String]: Required – This is the name of your existing Basic Balancer you want to upgrade.
    • newLBName: [String]:必需 – 这是要创建的标准负载均衡器的名称。newLBName: [String]: Required – This is the name for the Standard Load Balancer to be created.
  4. 使用相应的参数运行脚本。Run the script using the appropriate parameters. 完成该脚本可能需要 5 到 7 分钟时间。It may take five to seven minutes to finish.

    示例Example

    AzurePublicLBUpgrade.ps1 -oldRgName "test_publicUpgrade_rg" -oldLBName "LBForPublic" -newLbName "LBForUpgrade"
    

为出站连接创建出站规则Create an outbound rule for outbound connection

按照说明创建出站规则,以便执行以下操作:Follow the instructions to create an outbound rule so you can

  • 从头开始定义出站 NAT。Define outbound NAT from scratch.
  • 缩放和优化现有出站 NAT 的行为。Scale and tune the behavior of existing outbound NAT.

常见问题Common questions

用于将配置从 v1 迁移到 v2 的 Azure PowerShell 脚本是否存在任何限制?Are there any limitations with the Azure PowerShell script to migrate the configuration from v1 to v2?

是的。Yes. 请参阅注意事项/限制See Caveats/Limitations.

升级需要多长时间?How long does the upgrade take?

该脚本通常需要 5-10 分钟才能完成,并且可能需要更长的时间,具体取决于负载均衡器配置的复杂性。It usually take about 5-10 minutes for the script to finish and it could take longer depending on the complexity of your Load Balancer configuration. 因此,请记住故障时间,并在必要时做出故障转移的计划。Therefore, keep the downtime in mind and plan for failover if necessary.

Azure PowerShell 脚本是否还会将流量从基本负载均衡器切换到新建的标准负载均衡器?Does the Azure PowerShell script also switch over the traffic from my Basic Load Balancer to the newly created Standard Load Balancer?

是的。Yes. Azure PowerShell 脚本不仅升级公共 IP 地址,将配置从基本负载均衡器复制到标准负载均衡器,而且还将 VM 迁移到新建标准公共负载均衡器的后面。The Azure PowerShell script not only upgrades the Public IP address, copies the configuration from Basic to Standard Load Balancer, but also migrates VM to behind the newly created Standard Public Load Balancer as well.

后续步骤Next steps

了解标准负载均衡器Learn about Standard Load Balancer