Create or modify an Exchange peering using PowerShell
This article describes how to create a Microsoft Exchange peering by using PowerShell cmdlets and the 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
- Review the prerequisites and the Exchange peering walkthrough before you begin configuration.
- If you already have Exchange peerings with Microsoft that aren't converted to Azure resources, see Convert a legacy Exchange peering to an Azure resource by using PowerShell.
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. | |
Select the Cloud Shell button on the toolbar in the upper right of the Azure 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 an Exchange 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.
Install and import the Az module.
Install-Module Az -AllowClobber Import-Module Az
Install and import the Az.Peering module.
Install-Module -Name Az.Peering -AllowClobber Import-Module Az.Peering
Verify that the modules imported properly by using this command:
Get-Module
Sign in to your Azure account by using this command:
Connect-AzAccount
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"
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 Exchange 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 "Exchange"
Exchange peering locations contain the following fields:
- ExchangeName
- PeeringLocation
- Country
- PeeringDBFacilityId
- PeeringDBFacilityLink
- MicrosoftIPv4Address
- MicrosoftIPv6Address
Validate that you are present at the desired peering facility by referring to PeeringDB.
This example shows how to use Seattle as the peering location to create a peering.
$exchangeLocations = Get-AzPeeringLocation -Kind Exchange
$exchangeLocation = $exchangeLocations | where {$_.PeeringLocation -eq "Seattle"}
#check the location metadata
$exchangeLocation
ExchangeName : Columbia IX
PeeringLocation : Seattle
Country : US
PeeringDBFacilityId : 99999
PeeringDBFacilityLink : https://www.peeringdb.com/ix/99999
MicrosoftIPv4Address : 10.12.97.129
MicrosoftIPv6Address :
ExchangeName : Equinix Seattle
PeeringLocation : Seattle
Country : US
PeeringDBFacilityId : 11
PeeringDBFacilityLink : https://www.peeringdb.com/ix/11
MicrosoftIPv4Address : 198.32.134.152
MicrosoftIPv6Address : 2001:504:12::15
...
Create an Exchange peering
The following example shows how to create an Exchange connection at Equinix Internet Exchange in Seattle. If you're using a different provider and different settings, substitute that information when you make your request.
Use the PowerShell cmdlet New-AzPeeringExchangeConnectionObject to create PowerShell connection objects, which will be used to generate the new peering request.
This example shows how to create an Exchange connection.
$connection1 = New-AzPeeringExchangeConnectionObject `
-PeeringDBFacilityId $exchangeLocation[1].PeeringDBFacilityId `
-PeerSessionIPv4Address 198.32.134.22 `
-PeerSessionIPv6Address 2001:504:12::22 `
-MaxPrefixesAdvertisedIPv4 2000 `
-MaxPrefixesAdvertisedIPv6 2000 `
Create another connection in case you need redundancy at the given peering location.
$connection2 = New-AzPeeringExchangeConnectionObject `
-PeeringDBFacilityId $exchangeLocation[1].PeeringDBFacilityId `
-PeerSessionIPv4Address 198.32.134.23 `
-PeerSessionIPv6Address 2001:504:12::23 `
-MaxPrefixesAdvertisedIPv4 2000 `
-MaxPrefixesAdvertisedIPv6 2000 `
The PowerShell cmdlet New-AzPeering can be used to create a new Exchange peering.
$asn = Get-AzPeerAsn
New-AzPeering `
-Name "SeattleExchangePeering" `
-ResourceGroupName "PeeringResourceGroup" `
-PeerAsnResourceId $asn.Id `
-PeeringLocation $exchangeLocation[1].PeeringLocation `
-ExchangeConnection $connection1[, $connection2]
This example response shows when the request was executed by using one connection.
Name : SeattleExchangePeering
Sku.Name : Basic_Exchange_Free
Kind : Exchange
Connections : {11}
PeerAsn.Id : /subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}
PeeringLocation : Seattle
ProvisioningState : Succeeded
Location : West US 2
Id : /subscriptions/{subscriptionId}/resourceGroups/PeeringResourceGroup/providers/Microsoft.Peering/peerings/SeattleExchangePeering
Type : Microsoft.Peering/peerings
Tags : {}
Important
Microsoft starts provisioning the requested peering, and ConnectionState
reflects the progress.
For more information on provisioning-related steps, see the Exchange peering walkthrough.
You can check the connection state, as shown here.
$peering = Get-AzPeering -Name "SeattleExchangePeering" -ResourceGroupName "PeeringResourceGroup"
$peering.Connections
PeeringDBFacilityId : 11
PeerSessionIPv4Address : 198.32.134.22
PeerSessionIPv6Address : 2001:504:12::22
SessionStateV4 : PendingAdd
SessionStateV6 : PendingAdd
MaxPrefixesAdvertisedV4 : 2000
MaxPrefixesAdvertisedV6 : 2000
MicrosoftSessionIPv4Address : 198.32.134.152
MicrosoftSessionIPv4Address : 2001:504:12::15
Md5AuthenticationKey :
Get Exchange peering
To get the list of peerings, run the Get-AzPeering command.
Get-AzPeering ResourceGroupName "PeeringResourceGroup" -Name "SeattleExchangePeering"
This example response shows when the end-to-end provisioning was successfully completed.
Name : SeattleExchangePeering
Sku : Basic_Exchange_Free
Kind : Exchange
PeeringLocation : Seattle
ProvisioningState : Succeeded
PeerAsn : 65000
Connection : ------------------------
PeerSessionIPv4Address : 10.21.31.100
MicrosoftIPv4Address : 10.21.31.50
SessionStateV4 : Established
MaxPrefixesAdvertisedV4 : 20000
PeerSessionIPv6Address : fe01::3e:100
MicrosoftIPv6Address : fe01::3e:50
SessionStateV6 : Established
MaxPrefixesAdvertisedV6 : 2000
ConnectionState : Active
Connection : ------------------------
PeerSessionIPv4Address : 10.21.31.101
MicrosoftIPv4Address : 10.21.31.51
SessionStateV4 : Established
MaxPrefixesAdvertisedV4 : 20000
PeerSessionIPv6Address : fe01::3e:101
MicrosoftIPv6Address : fe01::3e:51
SessionStateV6 : Established
MaxPrefixesAdvertisedV6 : 2000
ConnectionState : Active
Modify an Exchange peering
The following modification operations are supported for Exchange peering:
- Add Exchange peering connections.
- Remove Exchange peering connections.
- Add an IPv4 or IPv6 session on Active connections.
- Remove an IPv4 or IPv6 session on Active connections.
Add Exchange peering connections
This example describes how to add connections to an existing Exchange peering.
$exchangePeering = Get-AzPeering -Name "SeattleExchangePeering" -ResourceGroupName "PeeringResourceGroup"
$connection = New-AzPeeringExchangeConnectionObject `
-PeeringDBFacilityId $exchangeLocation[1].PeeringDBFacilityId `
-PeerSessionIPv4Address 198.32.134.22 `
-PeerSessionIPv6Address 2001:504:12::22 `
-MaxPrefixesAdvertisedIPv4 2000 `
-MaxPrefixesAdvertisedIPv6 2000 `
$exchangePeering.Connections.Add($connection)
$exchangePeering | Update-AzPeering
Remove Exchange peering connections
This example describes how to remove connections to an existing Exchange peering.
$exchangePeering = Get-AzPeering -Name "SeattleExchangePeering" -ResourceGroupName "PeeringResourceGroup"
View all the connections, and select the connection you want to remove.
$exchangePeering
Name : SeattleExchangePeering
Sku.Name : Basic_Exchange_Free
Kind : Exchange
Connections : {11}
PeerAsn.Id : /subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}
PeeringLocation : Seattle
ProvisioningState : Succeeded
Location : West US 2
Id : /subscriptions/{subscriptionId}/resourceGroups/PeeringResourceGroup/providers/Microsoft.Peering/peerings/SeattleExchangePeering
Type : Microsoft.Peering/peerings
Tags : {}
In the following command, instead of 0, enter the index number for the connection you want to remove.
$connection = $exchangePeering.Connections[0]
$exchangePeering.Connections.Remove($connection)
$exchangePeering | Update-AzPeering
Add an IPv4 or IPv6 session on Active connections
This example describes how to add an IPv6 session to an existing Exchange connection.
$exchangePeering = Get-AzPeering -Name "SeattleExchangePeering" -ResourceGroupName "PeeringResourceGroup"
$exchangePeering.Connections[0].BgpSession.PeerSessionIPv6Address = "2001:504:12::34"
$exchangePeering | Update-AzPeering
Remove an IPv4 or IPv6 session 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 an Exchange 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