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

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

升级分为三个阶段:There are three stages in a upgrade:

  1. 迁移配置Migrate the configuration
  2. 将 VM 添加到标准负载均衡器的后端池Add VMs to backend pools of Standard Load Balancer

本文介绍配置迁移。This article covers configuration migration. 根据特定的环境,将 VM 添加到后端池的过程可能有所不同。Adding VMs to backend pools may vary depending on your specific environment. 不过,本文提供了一些概要性的普通建议However, some high-level, general recommendations are provided.

升级概述Upgrade overview

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

  • 在指定的资源组和位置中创建标准 SKU 负载均衡器。Creates a Standard SKU Load Balancer in the resource group and location the you specify.
  • 将基本 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.
  • 标准负载均衡器使用新的公共地址。The Standard Load Balancer has a new public address. 无法将与现有基本负载均衡器关联的 IP 地址无缝移动到标准负载均衡器,因为两者的 SKU 不同。It's impossible to move the IP addresses associated with existing Basic Load Balancer seamlessly to Standard Load Balancer since they have different SKUs.
  • 如果标准负载均衡器是在不同的区域中创建的,则无法将旧区域中的 VM 关联到新建的标准负载均衡器。If the Standard load balancer is created in a different region, you won't be able to associate the VMs existing in the old region to the newly created Standard Load Balancer. 若要克服此限制,请确保在新区域中创建新的 VM。To work around this limitation, make sure to create a new VM in the new region.
  • 如果负载均衡器没有任何前端 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.

下载脚本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 -Environment AzureChinaCloud 连接到 Azure。Use Connect-AzAccount -Environment AzureChinaCloud 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.
    • newrgName: [String]:必需 – 这是要在其中创建标准负载均衡器的资源组。newrgName: [String]: Required – This is the resource group in which the Standard Load Balancer will be created. 它可以是新资源组,也可以是现有资源组。It can be a new resource group or an existing one. 如果选择现有资源组,请注意,负载均衡器的名称在资源组中必须是唯一的。If you pick an existing resource group, note that the name of the Load Balancer has to be unique within the resource group.
    • newlocation: [String]:必需 – 这是要在其中创建标准负载均衡器的位置。newlocation: [String]: Required – This is the location in which the Standard Load Balancer will be created. 建议将所选基本负载均衡器的相同位置继承到标准负载均衡器,以方便与其他现有资源相关联。It is recommended to inherit the same location of the chosen Basic Load Balancer to the Standard Load Balancer for better association with other existing resources.
    • 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" -newrgName "test_userInput3_rg" -newlocation "chinaeast" -newLbName "LBForUpgrade"
    

将 VM 添加到标准负载均衡器的后端池Add VMs to backend pools of Standard Load Balancer

首先,请仔细检查脚本是否已成功创建一个新的标准公共负载均衡器,其上的配置完全是从基本公共负载均衡器迁移的。First, double check that the script successfully created a new Standard Public Load Balancer with the exact configuration migrated over from your Basic Public Load Balancer. 可以从 Azure 门户验证此结果。You can verify this from the Azure portal.

确保通过标准负载均衡器发送少量的流量作为手动测试。Be sure to send a small amount of traffic through the Standard Load Balancer as a manual test.

以下几种方案说明了如何配置将 VM 添加到新建标准公共负载均衡器的后端池,我们提供了每种方案的建议:Here are a few scenarios of how you add VMs to backend pools of the newly created Standard Public Load Balancer may be configured, and our recommendations for each one:

  • 将现有 VM 从旧基本公共负载均衡器的后端池移到新建标准公共负载均衡器的后端池Moving existing VMs from backend pools of old Basic Public Load Balancer to backend pools of newly created Standard Public Load Balancer.

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

    2. 在左侧菜单中选择“所有资源”,然后从资源列表中选择“新建的标准负载均衡器”。 Select All resources on the left menu, and then select the newly created Standard Load Balancer from the resource list.

    3. 在“设置”下,选择“后端池”。 Under Settings, select Backend pools.

    4. 选择与基本负载均衡器的后端池匹配的后端池,然后选择以下值:Select the backend pool which matches the backend pool of the Basic Load Balancer, select the following value:

    • 虚拟机:单击下拉控件,从基本负载均衡器的匹配后端池中选择 VM。Virtual Machine: Drop down and select the VMs from the matching backend pool of the Basic Load Balancer.
    1. 选择“保存” 。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.

为出站连接创建出站规则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.

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

否。No. 该 Azure PowerShell 脚本只会迁移配置。The Azure PowerShell script only migrates the configuration. 实际的流量迁移由你负责和控制。Actual traffic migration is your responsibility and in your control.

使用此脚本时我遇到了一些问题。I ran into some issues with using this script. 如何求助?How can I get help?

可以向 slbupgradesupport@microsoft.com 发送电子邮件、向 Azure 支持部门提交支持案例,或同时采取这两种措施。You can send an email to slbupgradesupport@microsoft.com, open a support case with Azure Support, or do both.

后续步骤Next steps

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