本文介绍如何使用 PowerShell 命令工具将现有的旧版直接对等互连转换为 Azure 资源。
在您开始之前
使用 Azure PowerShell
若要运行 cmdlet,可以使用 Azure Cloud Shell(一个免费的交互式 shell)。 它预安装了常用的 Azure 工具,并配置为可与你的帐户一起使用。 选择“复制”以复制代码,并将其粘贴到 Cloud Shell。 然后选择Enter以运行它。 可通过多种方式来启动 Cloud Shell:
启动方法 | 屏幕截图 |
---|---|
在浏览器中打开 Cloud Shell。 | ![]() |
选择 Azure 门户右上角工具栏上的“Cloud Shell”按钮。 |
![]() |
如果不想使用 Azure Cloud Shell,则可以改为在本地安装 PowerShell。 如果选择在本地安装和使用 PowerShell,请务必安装最新版本的 Azure 资源管理器 PowerShell cmdlet。 PowerShell 命令行脚本频繁更新。 你通常需要更新 PowerShell cmdlet 才能获取最新的功能。 如果你不这样做,可能会遇到问题。
若要查找你在本地运行的 PowerShell 版本,请使用“Get-Module -ListAvailable Az”cmdlet。 若要更新,请参阅安装 Azure PowerShell 模块。 有关详细信息,请参阅如何安装和配置 Azure PowerShell。
如果在 macOS 上使用 PowerShell,请按照在 macOS 上安装 PowerShell 中的步骤操作。
将旧版 Direct 对等互连转换为 Azure 资源
登录到 Azure 帐户,然后选择订阅
在开始配置之前,请安装并导入所需的模块。 你需要具有管理员权限才能在 PowerShell 中安装模块。
安装并导入 Az 模块。
Install-Module Az -AllowClobber Import-Module Az
安装并导入 Az.Peering 模块。
Install-Module -Name Az.Peering -AllowClobber Import-Module Az.Peering
使用此命令验证是否已正确导入模块:
Get-Module
使用以下命令登录到 Azure 帐户:
Connect-AzAccount
检查帐户中的订阅,并选择您想要创建对等互连的订阅。
Get-AzSubscription Select-AzSubscription -SubscriptionId "subscription-id"
如果还没有资源组,则在创建对等连接之前,必须先创建一个资源组。 为此,可以运行以下命令:
New-AzResourceGroup -Name "PeeringResourceGroup" -Location "Central US"
重要
如果尚未关联 ASN 和订阅,请参照关联对等 ASN 中的步骤进行操作。 为了请求对等互连,需要执行此操作。
注释
资源组的位置与您选择设置对等连接的位置无关。
获取用于转换的旧版直接对等连接
此示例演示如何在西雅图对等位置获取传统 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
转换传统直接对等互连
重要
将传统对等互连转换为 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