Connect a virtual network to an ExpressRoute circuit using PowerShell (classic)
This article will help you link virtual networks (VNets) to Azure ExpressRoute circuits using PowerShell. A single VNet can be linked to up to four ExpressRoute circuits. Use the steps in this article to create a new link to each ExpressRoute circuit you are connecting to. The ExpressRoute circuits can be in the same subscription, different subscriptions, or a mix of both. This article applies to virtual networks created using the classic deployment model.
You can link up to 10 virtual networks to an ExpressRoute circuit. All virtual networks must be in the same geopolitical region. You can link a larger number of virtual networks to your ExpressRoute circuit, or link virtual networks that are in other geopolitical regions if you enable the ExpressRoute premium add-on. Check the FAQ for more details about the premium add-on.
As of March 1, 2017, you can't create new ExpressRoute circuits in the classic deployment model.
- You can move an existing ExpressRoute circuit from the classic deployment model to the Resource Manager deployment model without experiencing any connectivity down time. For more information, see Move an existing circuit.
- You can connect to virtual networks in the classic deployment model by setting allowClassicOperations to TRUE.
Use the following links to create and manage ExpressRoute circuits in the Resource Manager deployment model:
About Azure deployment models
Azure currently works with two deployment models: Resource Manager and classic. The two models are not completely compatible with each other. Before you begin, you need to know which model that you want to work in. For information about the deployment models, see Understanding deployment models. If you are new to Azure, we recommend that you use the Resource Manager deployment model.
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure PowerShell.
- Review the prerequisites, routing requirements, and workflows before you begin configuration.
- You must have an active ExpressRoute circuit.
- Follow the instructions to create an ExpressRoute circuit and have your connectivity provider enable the circuit.
- Ensure that you have Azure private peering configured for your circuit. See the Configure routing article for routing instructions.
- Ensure that Azure private peering is configured and the BGP peering between your network and Microsoft is up so that you can enable end-to-end connectivity.
- You must have a virtual network and a virtual network gateway created and fully provisioned. Follow the instructions to configure a virtual network for ExpressRoute.
Download the latest PowerShell cmdlets
Install the latest versions of the Azure Service Management (SM) PowerShell modules and the ExpressRoute module. When using the following example, note that the version number (in this example, 5.1.1) will change as newer versions of the cmdlets are released.
Import-Module 'C:\Program Files\WindowsPowerShell\Modules\Azure\5.1.1\Azure\Azure.psd1' Import-Module 'C:\Program Files\WindowsPowerShell\Modules\Azure\5.1.1\ExpressRoute\ExpressRoute.psd1'
If you need more information about Azure PowerShell, see Getting started with Azure PowerShell cmdlets for step-by-step guidance on how to configure your computer to use the Azure PowerShell modules.
To sign in to your Azure account, use the following examples:
Open your PowerShell console with elevated rights and connect to your account.
Check the subscriptions for the account.
If you have more than one subscription, select the subscription that you want to use.
Select-AzSubscription -SubscriptionName "Replace_with_your_subscription_name"
Next, use the following cmdlet to add your Azure subscription to PowerShell for the classic deployment model.
Connect a virtual network in the same subscription to a circuit
You can link a virtual network to an ExpressRoute circuit by using the following cmdlet. Make sure that the virtual network gateway is created and is ready for linking before you run the cmdlet.
New-AzureDedicatedCircuitLink -ServiceKey "*****************************" -VNetName "MyVNet" Provisioned
Remove a virtual network link to a circuit
You can remove a virtual network link to an ExpressRoute circuit by using the following cmdlet. Make sure that the current subscription is selected for the given virtual network.
Remove-AzureDedicatedCircuitLink -ServiceKey "*****************************" -VNetName "MyVNet"
Connect a virtual network in a different subscription to a circuit
You can share an ExpressRoute circuit across multiple subscriptions. The following figure shows a simple schematic of how sharing works for ExpressRoute circuits across multiple subscriptions.
Each of the smaller clouds within the large cloud is used to represent subscriptions that belong to different departments within an organization. Each of the departments within the organization can use their own subscription for deploying their services--but the departments can share a single ExpressRoute circuit to connect back to your on-premises network. A single department (in this example: IT) can own the ExpressRoute circuit. Other subscriptions within the organization can use the ExpressRoute circuit.
Connectivity and bandwidth charges for the dedicated circuit will be applied to the ExpressRoute circuit owner. All virtual networks share the same bandwidth.
The circuit owner is the administrator/coadministrator of the subscription in which the ExpressRoute circuit is created. The circuit owner can authorize administrators/coadministrators of other subscriptions, referred to as circuit users, to use the dedicated circuit that they own. Circuit users who are authorized to use the organization's ExpressRoute circuit can link the virtual network in their subscription to the ExpressRoute circuit after they are authorized.
The circuit owner has the power to modify and revoke authorizations at any time. Revoking an authorization will result in all links being deleted from the subscription whose access was revoked.
Circuit owner operations
Creating an authorization
The circuit owner authorizes the administrators of other subscriptions to use the specified circuit. In the following example, the administrator of the circuit (Contoso IT) enables the administrator of another subscription (Dev-Test) to link up to two virtual networks to the circuit. The Contoso IT administrator enables this by specifying the Dev-Test Microsoft ID. The cmdlet doesn't send email to the specified Microsoft ID. The circuit owner needs to explicitly notify the other subscription owner that the authorization is complete.
New-AzureDedicatedCircuitLinkAuthorization -ServiceKey "**************************" -Description "Dev-Test Links" -Limit 2 -MicrosoftIds 'firstname.lastname@example.org'
Description : Dev-Test Links Limit : 2 LinkAuthorizationId : ********************************** MicrosoftIds : email@example.com Used : 0
The circuit owner can review all authorizations that are issued on a particular circuit by running the following cmdlet:
Get-AzureDedicatedCircuitLinkAuthorization -ServiceKey: "**************************"
Description : EngineeringTeam Limit : 3 LinkAuthorizationId : #################################### MicrosoftIds : firstname.lastname@example.org Used : 1 Description : MarketingTeam Limit : 1 LinkAuthorizationId : @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ MicrosoftIds : email@example.com Used : 0 Description : Dev-Test Links Limit : 2 LinkAuthorizationId : &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& MicrosoftIds : firstname.lastname@example.org Used : 2
The circuit owner can modify authorizations by using the following cmdlet:
Set-AzureDedicatedCircuitLinkAuthorization -ServiceKey "**************************" -AuthorizationId "&&&&&&&&&&&&&&&&&&&&&&&&&&&&"-Limit 5
Description : Dev-Test Links Limit : 5 LinkAuthorizationId : &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& MicrosoftIds : email@example.com Used : 0
The circuit owner can revoke/delete authorizations to the user by running the following cmdlet:
Remove-AzureDedicatedCircuitLinkAuthorization -ServiceKey "*****************************" -AuthorizationId "###############################"
Circuit user operations
The circuit user can review authorizations by using the following cmdlet:
Bandwidth : 200 CircuitName : ContosoIT Location : Washington DC MaximumAllowedLinks : 2 ServiceKey : &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ServiceProviderName : equinix ServiceProviderProvisioningState : Provisioned Status : Enabled UsedLinks : 0
Redeeming link authorizations
The circuit user can run the following cmdlet to redeem a link authorization:
New-AzureDedicatedCircuitLink –servicekey "&&&&&&&&&&&&&&&&&&&&&&&&&&" –VnetName 'SalesVNET1'
State VnetName ----- -------- Provisioned SalesVNET1
Run this command in the newly linked subscription for the virtual network:
New-AzureDedicatedCircuitLink -ServiceKey "*****************************" -VNetName "MyVNet"
For more information about ExpressRoute, see the ExpressRoute FAQ.
Send feedback about: