Editja

Ixxerja permezz ta’


Create or modify a Direct peering using PowerShell

This article describes how to create a Microsoft Direct peering by using PowerShell cmdlets and the Azure Resource Manager deployment model. This article also shows you how to check the status of the resource, update it, or delete and deprovision it.

If you prefer, you can complete this guide by using the Azure portal.

Before you begin

Work with Azure PowerShell

To run the cmdlets, you can use Azure Cloud Shell, a free interactive shell. It has common Azure tools preinstalled and configured to use with your account. Select Copy to copy the code, and paste it into Cloud Shell. Then select Enter to run it. There are a few ways to launch Cloud Shell:

Launch Method Screenshot
Open Cloud Shell in your browser. https://shell.azure.com/powershell
Select the Cloud Shell button on the toolbar in the upper right of the Azure portal. Cloud Shell in the portal

If you don't want to use Azure Cloud Shell, you can install PowerShell locally instead. If you choose to install and use PowerShell locally, be sure to install the latest version of the Azure Resource Manager PowerShell cmdlets. PowerShell cmdlets are updated frequently. You typically need to update your PowerShell cmdlets to get the latest feature functionality. If you don't, you might encounter issues.

To find the version of PowerShell that you're running locally, use the 'Get-Module -ListAvailable Az' cmdlet. To update, see Install the Azure PowerShell module. For more information, see how to install and configure Azure PowerShell.

If you use PowerShell on macOS, follow the steps in Installing PowerShell on macOS.

Create and provision a Direct peering

Sign in to your Azure account and select your subscription

Before you begin configuration, install and import the required modules. You need Administrator privileges to install modules in PowerShell.

  1. Install and import the Az module.

    Install-Module Az -AllowClobber
    Import-Module Az
    
  2. Install and import the Az.Peering module.

    Install-Module -Name Az.Peering -AllowClobber
    Import-Module Az.Peering
    
  3. Verify that the modules imported properly by using this command:

    Get-Module
    
  4. Sign in to your Azure account by using this command:

    Connect-AzAccount
    
  5. Check the subscriptions for the account, and select the subscription in which you want to create a peering.

    Get-AzSubscription
    Select-AzSubscription -SubscriptionId "subscription-id"
    
  6. If you don't already have a resource group, you must create one before you create a peering. You can do so by running the following command:

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

Important

If you haven't already associated your ASN and subscription, follow the steps in Associate Peer ASN. This action is required to request a peering.

Note

The location of a resource group is independent of the location where you choose to set up a peering.  

Get the list of supported peering locations for Direct peering

The PowerShell cmdlet Get-AzPeeringLocation returns a list of peering locations with the mandatory parameter Kind, which you'll use in later steps.

Get-AzPeeringLocation -Kind Direct

Direct peering locations contain the following fields:

  • PeeringLocation
  • Country
  • PeeringDBFacilityId
  • PeeringDBFacilityLink
  • BandwidthOffers

Validate that you're present at the desired peering facility by referring to PeeringDB.

This example shows how to use Seattle as the peering location to create a Direct peering.

$peeringLocations = Get-AzPeeringLocation -Kind Direct
$peeringLocation = $peeringLocations | where {$_.PeeringLocation -contains "Seattle"}
$peeringLocation

PeeringLocation       : Seattle
Address               : 2001 Sixth Avenue
Country               : US
PeeringDBFacilityId   : 71
PeeringDBFacilityLink : https://www.peeringdb.com/fac/71
BandwidthOffers       : {10Gbps, 100Gbps}

Create a Direct peering

The following example shows how to create a 10-Gbps Direct peering in Seattle.

Use the PowerShell cmdlet New-AzPeeringDirectConnectionObject to create DirectConnection objects that are to be used in the new peering request.

This example shows how to create a DirectConnection object.

$connection1 = New-AzPeeringDirectConnectionObject `
    -PeeringDBFacilityId $peeringLocation[0].PeeringDBFacilityId `
    -SessionPrefixV4 10.21.31.0/31 `
    -SessionPrefixV6 fe01::3e:0/127 `
    -MaxPrefixesAdvertisedIPv4 1000 `
    -MaxPrefixesAdvertisedIPv6 100 `
    -BandwidthInMbps 10000

Note

The value for $peeringLocation[] in the previous example should correspond to the peering location of your choice.

Create another connection in case you need redundancy at a given peering location.

$connection2 = New-AzPeeringDirectConnectionObject `
    -PeeringDBFacilityId $peeringLocation[0].PeeringDBFacilityId `
    -SessionPrefixV4 10.21.33.0/31 `
    -SessionPrefixV6 fe01::3f:0/127 `
    -MaxPrefixesAdvertisedIPv4 1000 `
    -MaxPrefixesAdvertisedIPv6 100 `
    -BandwidthInMbps 10000

Use the PowerShell cmdlet New-AzPeering to create a new Direct peering. This command requires an ASN resource ID, which can be retrieved as shown here.

$asn = Get-AzPeerAsn
New-AzPeering `
    -Name "SeattleDirectPeering" `
    -ResourceGroupName "PeeringResourceGroup" `
    -PeeringLocation  $peeringLocation[0].PeeringLocation `
    -PeerAsnResourceId $asn.Id `
    -DirectConnection $connection1 [, $connection2]

 

This example shows the response when the request was processed successfully.


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

Note that in place of {subscriptionId} in this output, the actual subscription ID will be displayed.

Verify Direct peering

To get the list of peerings, run the Get-AzPeering command.

$directPeering = Get-AzPeering -ResourceGroupName "PeeringResourceGroup" -Name "SeattleDirectPeering"

The following example shows the response when end-to-end provisioning was successfully completed.

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

Modify a Direct peering

This section describes how to perform the following modification operations for Direct peering:

  • Add Direct peering connections.
  • Remove Direct peering connections.
  • Upgrade or downgrade bandwidth on Active connections.
  • Add IPv4 or IPv6 sessions on Active connections.
  • Remove IPv4 or IPv6 sessions on Active connections.

Add Direct peering connections

This example describes how to add connections to existing Direct peering.


$directPeering = Get-AzPeering -Name "SeattleDirectPeering" -ResourceGroupName "PeeringResourceGroup"

$connection = New-AzPeeringDirectConnection `
    -PeeringDBFacilityId $peeringLocation.PeeringDBFacilityId `
    -SessionPrefixV4 "10.22.31.0/31" `
    -SessionPrefixV6 "fe02::3e:0/127" `
    -MaxPrefixesAdvertisedIPv4 1000 `
    -MaxPrefixesAdvertisedIPv6 100 `
    -BandwidthInMbps 10000

$directPeering.Connections.Add($connection)

$directPeering | Update-AzPeering

Remove Direct peering connections

Removing a connection isn't currently supported on PowerShell. For more information, contact Microsoft peering.

Upgrade or downgrade bandwidth on Active connections

This example describes how to add 10 Gbps to an existing Direct connection.


$directPeering = Get-AzPeering -Name "SeattleDirectPeering" -ResourceGroupName "PeeringResourceGroup"
$directPeering.Connections[0].BandwidthInMbps  = 20000
$directPeering | Update-AzPeering

Add IPv4 or IPv6 sessions on Active connections

This example describes how to add an IPv6 session on an existing Direct connection with only an IPv4 session.


$directPeering = Get-AzPeering -Name "SeattleDirectPeering" -ResourceGroupName "PeeringResourceGroup"
$directPeering.Connections[0].BGPSession.SessionPrefixv6 = "fe01::3e:0/127"
$directPeering | Update-AzPeering

Remove IPv4 or IPv6 sessions on Active connections

Removing an IPv4 or IPv6 session from an existing connection isn't currently supported on PowerShell. For more information, contact Microsoft peering.

Deprovision a Direct peering

Currently, deprovisioning isn't supported using the Azure portal or PowerShell. To deprovision, contact Microsoft peering.

Additional resources

You can get detailed descriptions of all the parameters by running the following command:

Get-Help Get-AzPeering -detailed

Next steps