共用方式為


使用 PowerShell 將舊版直接對等互連轉換為 Azure 資源

本文說明如何使用 PowerShell Cmdlets,將現有的舊版 Direct 對等互連轉換成 Azure 資源。

開始之前

使用 Azure PowerShell

若要執行 Cmdlet,您可以使用 Azure Cloud Shell,一個免費的互動式命令殼。 它具有預先安裝和設定的共用 Azure 工具,可與您的帳戶搭配使用。 請選取 [複製] 以複製該程式碼,並將其貼到 Cloud Shell。 然後選取 Enter 來加以執行。 以下有幾種 Cloud Shell 的啟動方式:

啟動方法 螢幕快照
在您的瀏覽器中開啟 Cloud Shell。 https://shell.azure.com/powershell
請選取 Azure 入口網站右上方工具列的 [Cloud Shell] 按鈕。 入口網站中的 Cloud Shell

如果您不想使用 Azure Cloud Shell,您可改為在本機安裝 PowerShell。 如果您選擇在本機安裝及使用 PowerShell,請務必安裝最新版的 Azure Resource Manager PowerShell Cmdlet。 PowerShell Cmdlet 會經常更新。 您通常需要更新 PowerShell Cmdlet 以取得最新的功能。 如果您沒有這麼做,可能會遇到一些問題。

若要尋找您在本地執行的 PowerShell 版本,請使用 'Get-Module -ListAvailable Az' cmdlet。 若要更新,請參閱安裝 Azure PowerShell 模組。 如需詳細資訊,請參閱如何安裝並設定 Azure PowerShell

如果您在 macOS 上使用 PowerShell,請遵循在 macOS 上安裝 PowerShell的步驟。

將舊版直接對等互連轉換為 Azure 資源

登入您的 Azure 帳戶並且選取您的訂用帳戶

開始設定之前,請先安裝並匯入必要的模組。 您需要系統管理員權限,才能在 PowerShell 中安裝模組。

  1. 安裝和匯入 Az 模組。

    Install-Module Az -AllowClobber
    Import-Module Az
    
  2. 安裝和匯入 Az.Peering 模組。

    Install-Module -Name Az.Peering -AllowClobber
    Import-Module Az.Peering
    
  3. 使用此命令確認模組已正確匯入:

    Get-Module
    
  4. 使用以下命令登入您的 Azure 帳戶:

    Connect-AzAccount
    
  5. 檢查帳戶的訂閱,然後選取您要在其中建立對等互連的訂閱。

    Get-AzSubscription
    Select-AzSubscription -SubscriptionId "subscription-id"
    
  6. 若您還沒有資源群組,您必須在建立對等互連之前先建立一個資源群組。 您可以執行下列命令來這麼做:

    New-AzResourceGroup -Name "PeeringResourceGroup" -Location "Central US"
    

這很重要

如果您尚未將 ASN 和訂用帳戶關聯,請按照關聯 ASN 和訂用帳戶中的步驟進行。 要求對等互連需要執行此動作。

備註

資源群組的位置與您選擇的對等連線設定位置無關。  

獲取舊版Direct Peering以進行轉換

此範例示範如何在西雅圖的對等互連位置取得舊版 Direct Peering 連接。

$legacyPeering = Get-AzLegacyPeering `
    -Kind Direct -PeeringLocation "Seattle"
$legacyPeering

以下是範例回應:

Name                       :
Sku                        : Basic_Direct_Free
Kind                       : Direct
PeeringLocation            : Seattle
UseForPeeringService       : False
PeerAsn.Id                 :
Connection                 : ------------------------
PeeringDBFacilityId        : 71
SessionPrefixIPv4          : 4.71.156.72/30
PeerSessionIPv4Address     : 4.71.156.73
MicrosoftIPv4Address       : 4.71.156.74
SessionStateV4             : Established
MaxPrefixesAdvertisedV4    : 20000
SessionPrefixIPv6          : 2001:1900:2100::1e10/126
MaxPrefixesAdvertisedV6    : 2000
ConnectionState            : Active
BandwidthInMbps            : 0
ProvisionedBandwidthInMbps : 20000
Connection                 : ------------------------
PeeringDBFacilityId        : 71
SessionPrefixIPv4          : 4.68.70.140/30
PeerSessionIPv4Address     : 4.68.70.141
MicrosoftIPv4Address       : 4.68.70.142
SessionStateV4             : Established
MaxPrefixesAdvertisedV4    : 20000
SessionPrefixIPv6          : 2001:1900:4:3::cc/126
PeerSessionIPv6Address     : 2001:1900:4:3::cd
MicrosoftIPv6Address       : 2001:1900:4:3::ce
SessionStateV6             : Established
MaxPrefixesAdvertisedV6    : 2000
ConnectionState            : Active
BandwidthInMbps            : 0
ProvisionedBandwidthInMbps : 20000
ProvisioningState          : Succeeded

將舊版 Direct 對等互連進行轉換

 

這很重要

當您將傳統對等互連轉換為 Azure 資源時,不支援任何修改。  

使用此命令將傳統直接對等互連轉換為 Azure 資源:

$legacyPeering[0] | New-AzPeering `
    -Name "SeattleDirectPeering" `
    -ResourceGroupName "PeeringResourceGroup" `

以下是範例回應:

Name                 : SeattleDirectPeering
Sku.Name             : Basic_Direct_Free
Kind                 : Direct
Connections          : {11, 11}
PeerAsn.Id           : /subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{asnNumber}
UseForPeeringService : False
PeeringLocation      : Seattle
ProvisioningState    : Succeeded
Location             : centralus
Id                   : /subscriptions/{subscriptionId}/resourceGroups/PeeringResourceGroup/providers/Microsoft.Peering/peerings/SeattleDirectPeering
Type                 : Microsoft.Peering/peerings
Tags                 : {}

其他資源

您可以執行此指令來取得所有參數的詳細描述:

Get-Help Get-AzPeering -detailed

後續步驟