この記事では、PowerShell を使用して ExpressRoute 回線のピアリングを有効および無効にする方法について説明します。 ピアリングは、作成時に既定で有効になっています。 ピアリングを無効にすると、ExpressRoute 回線のプライマリとセカンダリ接続の両方の BGP セッションが切断されます。 Microsoft へのこのピアリングの接続が失われます。 ピアリングを有効にすると、ExpressRoute 回線のプライマリとセカンダリの接続の両方の BGP セッションが確立します。 Microsoft への接続は、このピアリングのために再接続されます。 ExpressRoute 回線上の Microsoft ピアリングと Azure プライベート ピアリングのピアリングを別々に有効および無効にすることができます。
ExpressRoute ピアリングをリセットすると役立つ可能性のあるシナリオが 2 つ存在します。
- ディザスター リカバリーの設計と実装をテストする場合。 たとえば、2 つの ExpressRoute 回線があるとします。 一方の回線のピアリングを無効にして、ネットワーク トラフィックをもう一方の回線に強制的にフェールオーバーするようにできます。
- ExpressRoute 回線の Azure プライベート ピアリングまたは Microsoft ピアリングのどちらかで BFD (Bidirectional Forwarding Detection) を有効にします。 BFD は、Azure プライベート ピアリングでは ExpressRoute 回線が 2018 年 8 月 1 日より後に作成され、Microsoft ピアリングでは ExpressRoute 回線が 2020 年 1 月 10 日より後に作成された場合、既定で有効です。 一覧表示された日付より前に回線が作成された場合は、ピアリングをリセットして BFD を有効にする必要があります。
Azure PowerShell を使用する
この記事の手順と例では、Azure PowerShell Az モジュールが使用されます。 Az モジュールをご利用のコンピューターにローカルにインストールするには、Azure PowerShell のインストールに関するページを参照してください。 Az モジュールの詳細については、「新しい Azure PowerShell Az モジュールの概要」を参照してください。 PowerShell コマンドレットは、頻繁に更新されます。 最新バージョンを実行していないと、手順で指定されている値は失敗する場合があります。 システムにインストールされている PowerShell のバージョンを確認するには、Get-Module -ListAvailable Az
コマンドレットを使用します。
Azure Cloud Shell を使用すると、Azure PowerShell または CLI をローカルにインストールしなくても、ほとんどの PowerShell コマンドレットおよび CLI コマンドを実行できます。 Azure Cloud Shell は、無料の対話型シェルで、一般的な Azure ツールが事前にインストールされており、アカウントで使用できるように構成されています。 この記事に含まれるコードを Azure Cloud Shell で実行するには、Cloud Shell セッションを開き、コード ブロック上の [コピー] ボタンを使ってコードをコピーし、Ctrl + Shift + V キー (Windows と Linux) または command + Shift + V キー (macOS) を押して Cloud Shell セッションに貼り付けます。 テキストを貼り付けても自動的には実行されません。コードを実行するには、Enter キーを押します。
Cloud Shell は、次のようにいくつかの方法で起動することができます。
オプション | Link |
---|---|
コード ブロックの右上隅にある [使ってみる] をクリックします。 | ![]() |
ブラウザーで Cloud Shell を開きます。 | ![]() |
Azure Portal の右上のメニューの [Cloud Shell] ボタンをクリックします。 | ![]() |
ピアリングをリセットする
PowerShell をローカルで実行している場合は、昇格された特権で PowerShell コンソールを開き、アカウントに接続します。 接続については、次の例を参考にしてください。
Connect-AzAccount
複数の Azure サブスクリプションを所有している場合には、アカウントのサブスクリプションをすべて確認します。
Get-AzSubscription
使用するサブスクリプションを指定します。
Select-AzSubscription -SubscriptionName "Replace_with_your_subscription_name"
次のコマンドを実行して、ExpressRoute 回線を取得します。
$ckt = Get-AzExpressRouteCircuit -Name "ExpressRouteARMCircuit" -ResourceGroupName "ExpressRouteResourceGroup"
無効または有効にするピアリングを識別します。 Peerings は配列です。 次の例では、Peerings[0] は Azure プライベート ピアリングであり、Peerings[1] は Microsoft ピアリングです。
Name : ExpressRouteARMCircuit ResourceGroupName : ExpressRouteResourceGroup Location : westus Id : /subscriptions/########-####-####-####-############/resourceGroups/ExpressRouteResourceGroup/providers/Microsoft.Network/expressRouteCircuits/ExpressRouteARMCircuit Etag : W/"cd011bef-dc79-49eb-b4c6-81fb6ea5d178" ProvisioningState : Succeeded Sku : { "Name": "Standard_MeteredData", "Tier": "Standard", "Family": "MeteredData" } CircuitProvisioningState : Enabled ServiceProviderProvisioningState : Provisioned ServiceProviderNotes : ServiceProviderProperties : { "ServiceProviderName": "Coresite", "PeeringLocation": "Los Angeles", "BandwidthInMbps": 50 } ServiceKey : ########-####-####-####-############ Peerings : [ { "Name": "AzurePrivatePeering", "Etag": "W/\"cd011bef-dc79-49eb-b4c6-81fb6ea5d178\"", "Id": "/subscriptions/########-####-####-####-############/resourceGroups/ExpressRouteResourceGroup/providers/Microsoft.Network/expressRouteCircuits/ExpressRouteARMCircuit/peerings/AzurePrivatePeering", "PeeringType": "AzurePrivatePeering", "State": "Enabled", "AzureASN": 12076, "PeerASN": 123, "PrimaryPeerAddressPrefix": "10.0.0.0/30", "SecondaryPeerAddressPrefix": "10.0.0.4/30", "PrimaryAzurePort": "", "SecondaryAzurePort": "", "VlanId": 789, "MicrosoftPeeringConfig": { "AdvertisedPublicPrefixes": [], "AdvertisedCommunities": [], "AdvertisedPublicPrefixesState": "NotConfigured", "CustomerASN": 0, "LegacyMode": 0, "RoutingRegistryName": "NONE" }, "ProvisioningState": "Succeeded", "GatewayManagerEtag": "", "LastModifiedBy": "Customer", "Connections": [] }, { "Name": "MicrosoftPeering", "Etag": "W/\"cd011bef-dc79-49eb-b4c6-81fb6ea5d178\"", "Id": "/subscriptions/########-####-####-####-############/resourceGroups/ExpressRouteResourceGroup/providers/Microsoft.Network/expressRouteCircuits/ExpressRouteARMCircuit/peerings/MicrosoftPeering", "PeeringType": "MicrosoftPeering", "State": "Enabled", "AzureASN": 12076, "PeerASN": 123, "PrimaryPeerAddressPrefix": "3.0.0.0/30", "SecondaryPeerAddressPrefix": "3.0.0.4/30", "PrimaryAzurePort": "", "SecondaryAzurePort": "", "VlanId": 345, "MicrosoftPeeringConfig": { "AdvertisedPublicPrefixes": [ "3.0.0.3/32" ], "AdvertisedCommunities": [], "AdvertisedPublicPrefixesState": "ValidationNeeded", "CustomerASN": 0, "LegacyMode": 0, "RoutingRegistryName": "NONE" }, "ProvisioningState": "Succeeded", "GatewayManagerEtag": "", "LastModifiedBy": "Customer", "Connections": [] } ] Authorizations : [] AllowClassicOperations : False GatewayManagerEtag :
次のコマンドを実行して、ピアリングの状態を無効に変更します。
$ckt.Peerings[0].State = "Disabled" Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt
ピアリングが、設定した無効状態になります。
次のコマンドを実行して、ピアリングの状態を有効に戻します。
$ckt.Peerings[0].State = "Enabled" Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt
ピアリングが、設定した有効状態になります。
次のステップ
ExpressRoute の問題をトラブルシューティングするためにサポートが必要な場合は、次の記事をご覧ください。