Nota
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
本文可帮助你使用虚拟 WAN 通过 ExpressRoute 线路来连接到 Azure 中的资源。 有关虚拟 WAN 中的 ExpressRoute 的更多概念性信息,请参阅关于虚拟 WAN 中的 ExpressRoute。
在开始配置之前,请验证你是否符合以下条件。
你拥有一个要连接到的虚拟网络。 确认本地网络的任何子网都不会与要连接到的虚拟网络重叠。 若要使用 PowerShell 创建虚拟网络,请参阅快速入门。
虚拟网络不包含任何虚拟网络网关。 如果虚拟网络包含网关(VPN 或 ExpressRoute),则必须删除所有网关。 此配置要求将虚拟网络改为连接到虚拟 WAN 中心网关。
获取虚拟中心区域的 IP 地址范围。 虚拟中心是虚拟 WAN 创建和使用的虚拟网络。 为虚拟中心指定的地址范围不能与要连接到的任何现有虚拟网络重叠。 此外,它也不能与连接到本地的地址范围重叠。 如果不熟悉本地网络配置中的 IP 地址范围,请咨询能够提供此类详细信息的人员。
以下 ExpressRoute 线路 SKU 可以连接到中心网关:本地、标准和高级。
如果没有 Azure 订阅,请创建一个试用版订阅。
可以在计算机本地安装并运行 Azure PowerShell cmdlet。 PowerShell cmdlet 经常更新。 如果尚未安装最新版本,说明中指定的值可能会失败。 若要查找计算机上安装的 Azure PowerShell 版本,请使用 Get-Module -ListAvailable Az
cmdlet。 若要进行安装或更新,请参阅安装 Azure PowerShell 模块。
使用提升的权限打开 PowerShell 控制台,并连接到 Azure 帐户。
Connect-AzAccount -Environment AzureChinaCloud
cmdlet 将提示你输入凭据。 进行身份验证后,它会下载帐户设置,以便 Azure PowerShell 可以使用这些设置。 可以使用 Get-AzSubscription
和 Select-AzSubscription -SubscriptionName "Name of subscription"
更改订阅。
创建虚拟 WAN 之前,必须先创建资源组来托管虚拟 WAN 或使用现有的资源组。 使用以下示例之一。
新资源组 - 此示例在“中国东部 2”位置创建一个名为 testRG 的新资源组。
创建资源组。
New-AzResourceGroup -Location "chinaeast2" -Name "testRG"
创建虚拟 WAN。
$virtualWan = New-AzVirtualWan -ResourceGroupName testRG -Name myVirtualWAN -Location "chinaeast2"
现有资源组 - 如果要在现有资源组中创建虚拟 WAN,请按照以下步骤操作。
为现有资源组设置变量。
$resourceGroup = Get-AzResourceGroup -ResourceGroupName "testRG"
创建虚拟 WAN。
$virtualWan = New-AzVirtualWan -ResourceGroupName testRG -Name myVirtualWAN -Location "chinaeast2"
使用以下示例之一在新的或现有虚拟中心创建 ExpressRoute 网关。
新虚拟中心 - 此示例使用指定的地址前缀和虚拟中心的位置创建名为“chinaeast2hub”的默认虚拟中心。
创建虚拟中心。
$virtualHub = New-AzVirtualHub -VirtualWan $virtualWan -ResourceGroupName "testRG" -Name "chinaeast2hub" -AddressPrefix "10.0.0.1/24"
创建 ExpressRoute 网关。 ExpressRoute 网关以 2 Gbps 为单位进行预配。 1 个缩放单元= 2 Gbps,最多支持 10 个缩放单元 = 20 Gbps。 完全创建虚拟中心和网关大约需要 30 分钟。
$expressroutegatewayinhub = New-AzExpressRouteGateway -ResourceGroupName "testRG" -Name "testergw" -VirtualHubId $virtualHub.Id -MinScaleUnits 2
现有虚拟中心 - 此示例在现有虚拟中心创建 ExpressRoute 网关。
$expressroutegatewayinhub = New-AzExpressRouteGateway -MaxScaleUnits <UInt32> -MinScaleUnits 2 -Name 'testExpressRoutegw' -ResourceGroupName 'testRG' -Tag @{"tag1"="value1"; "tag2"="value2"} -VirtualHubName "[hub Name]"
下一步是获取 ExpressRoute 线路的专用对等互连 ID。 可以创建新线路,也可以从现有线路获取 ID。 使用以下示例之一。
新线路 - 此示例创建新的 ExpressRoute 线路并获取其专用对等互连 ID。
$ExpressRouteCircuit = New-AzExpressRouteCircuit -ResourceGroupName "testRG" -Name "testExpressRouteCircuit" -Location "chinaeast2" -SkuTier Premium -SkuFamily MeteredData -ServiceProviderName "Equinix" -PeeringLocation "Silicon Valley" -BandwidthInMbps 200
Add-AzExpressRouteCircuitPeeringConfig -Name "AzurePrivatePeering" -ExpressRouteCircuit $ExpressRouteCircuit -PeeringType AzurePrivatePeering -PeerASN 100 -PrimaryPeerAddressPrefix "123.0.0.0/30" -SecondaryPeerAddressPrefix "123.0.0.4/30" -VlanId 300
$ExpressRouteCircuit = Set-AzExpressRouteCircuit -ExpressRouteCircuit $ExpressRouteCircuit
$ExpressRouteCircuitPeeringId = $ExpressRouteCircuit.Peerings[0].Id
现有线路 - 此示例从现有 ExpressRoute 线路获取详细信息和专用对等互连 ID。
$ExpressRouteCircuit = Get-AzExpressRouteCircuit -ResourceGroupName ["resource group name"] -Name ["expressroute circuit name"]
$ExpressRouteCircuitPeeringId = $ExpressRouteCircuit.Peerings[0].Id
在本部分中,需将 ExpressRoute (ER) 线路连接到虚拟中心的 ExpressRoute 网关。
使用以下示例之一连接线路。 这两个示例都包含可选的授权密钥步骤。
连接 - 示例 ER 网关 - 此示例将前面创建的 ExpressRoute 线路连接到虚拟中心的 ExpressRoute 网关 ($expressroutegatewayinhub)。
运行以下示例命令:
$ExpressrouteConnection = New-AzExpressRouteConnection -ResourceGroupName $expressroutegatewayinhub.ResourceGroupName -ExpressRouteGatewayName $expressroutegatewayinhub.Name -Name "testConnection" -ExpressRouteCircuitPeeringId $ExpressRouteCircuitPeeringId -RoutingWeight 20
可选 - 使用 ExpressRoute 线路的授权密钥进行连接
为 ExpressRoute 线路创建授权密钥。 有关步骤,请参阅如何创建授权。
创建授权后,获取 ER 线路的授权。
$authorizations = Get-AzExpressRouteCircuitAuthorization -ExpressRouteCircuit $ExpressRouteCircuit
为第一个密钥获取授权密钥;对其他密钥使用索引(即 [1])。
$authorizationskey = $authorizationskey[0].AuthorizationKey
使用授权密钥将 ExpressRoute 线路连接到虚拟中心。
$ExpressrouteConnection = New-AzExpressRouteConnection -ResourceGroupName $expressroutegatewayinhub.ResourceGroupName -ExpressRouteGatewayName $expressroutegatewayinhub.Name -Name "testConnectionpowershellauthkey" -ExpressRouteCircuitPeeringId $ExpressRouteCircuitPeeringId -RoutingWeight 2 -AuthorizationKey $authprizationskey
连接 - 现有 ER 网关 - 此示例中的步骤可帮助你连接到现有的 ExpressRoute 网关。
获取现有的虚拟中心 ExpressRoute 网关详细信息。
$expressroutegatewayinhub = Get-AzExpressRouteGateway -ResourceId "[ERgatewayinhubID]"
将 ExpressRoute 线路连接到虚拟中心 ExpressRoute 网关。
$ExpressrouteConnection = New-AzExpressRouteConnection -ResourceGroupName $expressroutegatewayinhub.ResourceGroupName -ExpressRouteGatewayName $expressroutegatewayinhub.Name -Name "testConnection" -ExpressRouteCircuitPeeringId $ExpressRouteCircuitPeeringId -RoutingWeight 20
可选 - 使用 ExpressRoute 线路的授权密钥进行连接。
为 ExpressRoute 线路创建授权密钥。 有关步骤,请参阅如何创建授权。
创建授权后,获取 ER 线路的授权。
$authorizations = Get-AzExpressRouteCircuitAuthorization -ExpressRouteCircuit $ExpressRouteCircuit
为第一个密钥获取授权密钥;对其他密钥使用索引(即 [1])。
$authorizationskey = $authorizationskey[0].AuthorizationKey
将 ExpressRoute 线路连接到虚拟中心 ExpressRoute 网关。
$ExpressrouteConnection = New-AzExpressRouteConnection -ResourceGroupName $expressroutegatewayinhub.ResourceGroupName -ExpressRouteGatewayName $expressroutegatewayinhub.Name -Name "testConnectionpowershellauthkey" -ExpressRouteCircuitPeeringId $ExpressRouteCircuitPeeringId -RoutingWeight 2 -AuthorizationKey $authprizationskey
建立线路连接后,虚拟中心连接状态将指示“此中心”,这意味着已建立通向虚拟中心 ExpressRoute 网关的连接。 等待大约 5 分钟,然后再测试 ExpressRoute 线路后面的客户端(例如,先前创建的 VNet 中的 VM)的连接性。
在以下示例中,会将 ExpressRoute 网关修改为其他缩放单元(3 个缩放单元)。
Set-AzExpressRouteGateway -ResourceGroupName "testRG" -Name "testergw" -MinScaleUnits 3
接下来,若要详细了解虚拟 WAN 中的 ExpressRoute,请参阅: