升级 Azure 内部负载均衡器 - 不需出站连接Upgrade Azure Internal Load Balancer- No Outbound Connection Required

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.

本文介绍了一个 PowerShell 脚本,该脚本会创建一个其配置与基本负载均衡器相同的标准负载均衡器,并会将流量从基本负载均衡器迁移到标准负载均衡器。This article introduces a PowerShell script which creates a Standard Load Balancer with the same configuration as the Basic Load Balancer along with migrating traffic from Basic Load Balancer to Standard Load Balancer.

升级概述Upgrade overview

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

  • 在指定的位置中创建标准内部 SKU 负载均衡器。Creates a Standard Internal SKU Load Balancer in the location that you specify. 请注意,标准内部负载均衡器不会提供任何出站连接Note that no outbound connection will not be provided by the Standard Internal Load Balancer.
  • 将基本 SKU 负载均衡器的配置无缝复制到新建的标准负载均衡器。Seamlessly copies the configurations of the Basic SKU Load Balancer to the newly created Standard Load Balancer.
  • 将专用 IP 从基本负载均衡器无缝移到新建的标准负载均衡器。Seamlessly move the private IPs from Basic Load Balancer to the newly created Standard Load Balancer.
  • 将 VM 从基本负载均衡器的后端池无缝移到标准负载均衡器的后端池Seamlessly move the VMs from backend pool of the Basic Load Balancer to the backend pool of the Standard Load Balancer

注意事项/限制Caveats\Limitations

  • 脚本只支持不需要出站连接的内部负载均衡器升级。Script only supports Internal Load Balancer upgrade where no outbound connection is required. 如果需要用于某些 VM 的出站连接,请参阅此页面,了解相关说明。If you required outbound connection for some of your VMs, please refer to this page for instructions.
  • 基本负载均衡器需要与后端 VM 和 NIC 位于同一资源组中。The Basic Load Balancer needs to be in the same resource group as the backend VMs and NICs.
  • 如果标准负载均衡器是在不同的区域中创建的,则无法将旧区域中的 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. 确保负载均衡器不是空的。Make sure they are not empty.

将前端 IP 配置的 IP 分配方法更改为“静态”(如果此项已为“静态”,则忽略此步骤)Change IP allocation method to Static for frontend IP Configuration (Ignore this step if it's already static)

  1. 在左侧菜单中选择“所有服务”,接着选择“所有资源”,然后在资源列表中选择你的基本负载均衡器。 Select All services in the left-hand menu, select All resources, and then select your Basic Load Balancer from the resources list.

  2. 在“设置”下,选择“前端 IP 配置”,然后选择第一个前端 IP 配置。Under Settings, select Frontend IP Configuration, and select the first frontend IP configuration.

  3. 对于“分配”,请选择“静态”For Assignment, select Static

  4. 对于基本负载均衡器的所有前端 IP 配置,请重复执行步骤 3。Repeat the step 3 for all of the frontend IP configurations of the Basic Load Balancer.

下载脚本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 AzureILBUpgrade

此命令还会安装所需的 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:

    • rgName: [字符串]:必需 – 这是现有基本负载均衡器和新的标准负载均衡器的资源组。rgName: [String]: Required – This is the resource group for your existing Basic Load Balancer and new Standard Load Balancer. 若要查找此字符串值,请导航到 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.
    • 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

    AzureILBUpgrade.ps1 -rgName "test_InternalUpgrade_rg" -oldLBName "LBForInternal" -newlocation "chinaeast2" -newLbName "LBForUpgrade"
    

常见问题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?

是的,它会迁移流量。Yes it migrates traffic. 如果想要亲自迁移流量,请使用此脚本(它不会为你移动虚拟机)。If you would like to migrate traffic personally, use this script which does not move VMs for you.

使用此脚本时我遇到了一些问题。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