升級 Azure 內部 Load Balancer-不需要輸出連接Upgrade Azure Internal Load Balancer- No Outbound Connection Required

Azure Standard Load Balancer 透過區域冗余提供一組豐富的功能和高可用性。Azure Standard Load Balancer offers a rich set of functionality and high availability through zone redundancy. 若要深入瞭解 Load Balancer SKU,請參閱 比較表To learn more about Load Balancer SKU, see comparison table.

本文介紹 PowerShell 腳本,該腳本會使用與基本 Load Balancer 相同的設定來建立 Standard Load Balancer,並將流量從基本 Load Balancer 遷移至 Standard Load Balancer。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 Load Balancer。Creates a Standard Internal SKU Load Balancer in the location that you specify. 請注意,標準的內部 Load Balancer 不會提供任何 輸出連接Note that no outbound connection will not be provided by the Standard Internal Load Balancer.
  • 將基本 SKU Load Balancer 的設定順暢地複製到新建立的 Standard Load Balancer。Seamlessly copies the configurations of the Basic SKU Load Balancer to the newly created Standard Load Balancer.
  • 順暢地將私人 Ip 從基本 Load Balancer 移至新建立的 Standard Load Balancer。Seamlessly move the private IPs from Basic Load Balancer to the newly created Standard Load Balancer.
  • 將 Vm 從基本 Load Balancer 的後端集區順暢地移至 Standard Load Balancer 的後端集區Seamlessly move the VMs from backend pool of the Basic Load Balancer to the backend pool of the Standard Load Balancer

Caveats\LimitationsCaveats\Limitations

  • 腳本僅支援內部 Load Balancer 升級,但不需要任何輸出連接。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.
  • 基本 Load Balancer 必須與後端 Vm 和 Nic 位於相同的資源群組中。The Basic Load Balancer needs to be in the same resource group as the backend VMs and NICs.
  • 如果在不同區域中建立標準負載平衡器,您將無法將舊區域中現有的 Vm 與新建立的 Standard Load Balancer 建立關聯。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.
  • 如果您的 Load Balancer 沒有任何前端 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. 在左側功能表中選取 [ 所有服務 ],選取 [ 所有資源],然後從 [資源] 清單中選取您的基本 Load Balancer。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. 針對基本 Load Balancer 的所有前端 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 連接至 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:

    • rgName: [字串]:必要 項–這是您現有基本 Load Balancer 和新 Standard Load Balancer 的資源群組。rgName: [String]: Required – This is the resource group for your existing Basic Load Balancer and new Standard Load Balancer. 若要尋找此字串值,請流覽至 [Azure 入口網站],選取您的基本 Load Balancer 來源,然後按一下負載平衡器的 總覽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: [字串]:必要 項–這是您想要升級的現有基本平衡器名稱。oldLBName: [String]: Required – This is the name of your existing Basic Balancer you want to upgrade.
    • newlocation: [字串]:必要 項–這是將建立 Standard Load Balancer 的位置。newlocation: [String]: Required – This is the location in which the Standard Load Balancer will be created. 建議您將所選基本 Load Balancer 的相同位置繼承到 Standard Load Balancer,以便與其他現有資源更好的關聯。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: [字串]: Required –這是要建立之 Standard Load Balancer 的名稱。newLBName: [String]: Required – This is the name for the Standard Load Balancer to be created.
  4. 使用適當的參數執行腳本。Run the script using the appropriate parameters. 可能需要5到七分鐘才能完成。It may take five to seven minutes to finish.

    範例Example

    AzureILBUpgrade.ps1 -rgName "test_InternalUpgrade_rg" -oldLBName "LBForInternal" -newlocation "centralus" -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 腳本是否也會將基本 Load Balancer 的流量切換至新建立的 Standard Load Balancer?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. 如果您想要以個人的方式遷移流量,請使用 此腳本,此腳本 不會為您移動 vm。If you would like to migrate traffic personally, use this script which does not move VMs for you.

下一步Next steps

瞭解 Standard Load BalancerLearn about Standard Load Balancer