你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

使用 PowerShell 创建或更改对等互连服务连接

Azure 对等互连服务是一种网络服务,可增强与 Microsoft 云服务(例如 Microsoft 365、Dynamics 365、软件即服务 (SaaS) 服务、Azure 或可通过公共 Internet 访问的任何 Microsoft 服务)建立的连接。

本文介绍如何使用 Azure PowerShell 创建和更改对等互连服务连接。 若要了解如何使用 Azure 门户或 Azure CLI 管理对等互连服务连接,请参阅使用 Azure 门户创建、更改或删除对等互连服务连接使用 Azure CLI 创建、更改或删除对等互连服务连接

先决条件

  • 具有活动订阅的 Azure 帐户。 免费创建帐户

  • Azure Cloud Shell 或本地安装的 Azure PowerShell。

    本文中的步骤在 Azure Cloud Shell 中以交互方式运行 Azure PowerShell cmdlet 命令。 要在 Cloud Shell 中运行命令,请选择代码块右上角的“打开 Cloudshell”。 选择“复制”以复制代码,并将其粘贴到 Cloud Shell 以运行。 也可以从 Azure 门户中运行 Cloud Shell。

    也可以在本地安装 Azure PowerShell 以运行 cmdlet。 本文需要 Azure PowerShell 模块 1.0.0 或更高版本。 要查找已安装的版本,请运行 Get-Module -ListAvailable Az。 如果需要进行升级,请参阅 Install Azure PowerShell module(安装 Azure PowerShell 模块)。 如果在本地运行 PowerShell,请使用 Connect-AzAccount cmdlet 登录到 Azure。

  • 连接服务提供商。 有关详细信息,请参阅对等互连服务合作伙伴

将订阅注册到资源提供程序和功能标志

在继续执行创建对等互连服务的步骤之前,请使用 Register-AzResourceProviderRegister-AzProviderFeature 向资源提供程序和功能标志注册你的订阅:

# Register Microsoft.Peering provider.
Register-AzResourceProvider -ProviderNamespace Microsoft.Peering
# Register AllowPeeringService feature.
Register-AzProviderFeature -FeatureName AllowPeeringService -ProviderNamespace Microsoft.Peering 

列出对等互连服务位置和服务提供商

使用 Get-AzPeeringServiceCountry 列出可以使用对等互连服务的国家/地区,并使用 Get-AzPeeringServiceLocation 列出每个国家/地区中你可以获得对等互连服务的都市圈位置:

# List the countries/regions available for Peering Service.
Get-AzPeeringServiceCountry 
# List metro locations serviced in a country
Get-AzPeeringServiceLocation -Country "United States"

使用 Get-AzPeeringServiceProvider 获取可用对等服务提供商的列表:

Get-AzPeeringServiceProvider

创建对等互连服务连接

使用 New-AzPeeringService 创建对等互连服务连接:

New-AzPeeringService -ResourceGroupName myResourceGroup -Name myPeeringService -PeeringLocation Virginia -PeeringServiceProvider Contoso

添加对等互连服务前缀

使用 New-AzPeeringServicePrefix 添加连接提供商提供给你的前缀:

New-AzPeeringServicePrefix -ResourceGroupName myResourceGroup -PeeringServiceName myPeeringService -Name myPrefix -prefix 240.0.0.0/32 -ServiceKey 00000000-0000-0000-0000-000000000000

列出所有对等互连服务连接

若要查看所有对等互连服务连接的列表,请使用 Get-AzPeeringService

Get-AzPeeringService | Format-Table Name, PeeringServiceLocation, PeeringServiceProvider, Location

列出所有对等互连服务前缀

若要查看所有对等互连服务前缀的列表,请使用 Get-AzPeeringServicePrefix

Get-AzPeeringServicePrefix -PeeringServiceName myPeeringService -ResourceGroupName myResourceGroup

删除对等互连服务前缀

若要删除对等互连服务前缀,请使用 Remove-AzPeeringServicePrefix

Remove-AzPeeringServicePrefix -ResourceGroupName myResourceGroup -Name myPeeringService -PrefixName myPrefix