Convert a legacy Direct peering to an Azure resource using PowerShell

This article describes how to convert an existing legacy Direct peering to an Azure resource by using PowerShell cmdlets.

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.

Convert a legacy Direct peering to an Azure resource

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 a legacy Direct peering for conversion

This example shows how to get a legacy Direct peering at the Seattle peering location.

$legacyPeering = Get-AzLegacyPeering `
    -Kind Direct -PeeringLocation "Seattle"
$legacyPeering

Here's an example response:

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

Convert a legacy Direct peering

 

Important

When you convert a legacy peering to an Azure resource, modifications aren't supported.  

Use this command to convert a legacy Direct peering to an Azure resource:

$legacyPeering[0] | New-AzPeering `
    -Name "SeattleDirectPeering" `
    -ResourceGroupName "PeeringResourceGroup" `

Here's an example response:

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                 : {}

Additional resources

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

Get-Help Get-AzPeering -detailed

Next steps