Australia | Connecting Virtual Networks in different Azure Subscriptions to an ExpressRoute Circuit in Resource Manager

Richard Young - 29.03.2016

Connecting Virtual Networks in different Azure Subscriptions to an ExpressRoute Circuit in Resource Manager

Australia | Connecting Virtual Networks in different Azure Subscriptions to an ExpressRoute Circuit in Resource Manager

Scenario

I have an ExpressRoute circuit configured with a connexion to a Version 2 (Resource Manager) Azure Virtual Network. I also have an additional Virtual Network in a different Subscription which I need to connect to the same circuit.

The Issue

The instructions on connecting another Virtual Network in a different Subscription are a little confusing. It’s also worth noting that some of the parameters are different now with the latest version of the PowerShell Azure cmdlets. The original instructions may be found here

Environment

I have a Virtual Network in each of my two subscriptions:

  • Subscription 1: Production – Australia East
  • Subscription 2: Test/Dev -Australia Southeast

The primary ExpressRoute connexion is configured to use the “Production Australia East” Virtual Network.

Assumptions

The script assumes that you have performed the following work:

  • Configured ExpressRoute with a connexion to your primary Virtual Network
  • Added a /28 subnet into your target Virtual Network with the name “GatewaySubnet”
  • Created a Virtual Network Gateway in your target Virtual Network of type “ExpressRoute”

What the script does

The PowerShell script below performs the following steps:

  • Defines parameters for:
    • Source – The primary subscription and Virtual Network that ExpressRoute is configured to communicate with
    • Target – The subscription and Virtual Network that we would like to add a connexion to
  • Selects the source subscription
  • Gets information about the existing circuit into a variable
  • Creates an authorisation for a new connexion and places the information into a variable
  • Refreshes information about the circuit into the corresponding variable
  • Selects the target subscription
  • Gets information about the target gateway
  • Creates a new Network Gateway connection

The PowerShell Script

Ensure that the variable at the top of the script are changed to suit your needs.

Ensure that the target location specified is correct for the target Virtual Network, otherwise you receive the error “Unable to parse” which is not entirely helpful!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Define Source Parameters
$SourceSubscriptionName=’Prod01′
$SourceResourceGroupName=’ProdInfraEast’
 
$CircuitName=’EXP_Prod_aueast’
 
$AuthorisationName=’TestDev01Southeast’
 
# Define Target Parameters
$TargetResourceGroupName=’TestDevInfraSoutheast’
$TargetSubscriptionName=’TestDev01′
$TargetGatewayName=’GW_TestDev_auSoutheast’
$TargetConnectionName=’EXPCON_TestDev_auSoutheast’
$TargetLocation=’Australia Southeast’
# End editable parameters
#Login-AzureRmAccount
 
# Select Source Subscription
Select-AzureRmSubscription `
-SubscriptionName $SourceSubscriptionName
 
Write-Host ‘Getting initial variables’
# Get information about existing circuit
$Circuit = Get-AzureRmExpressRouteCircuit `
-Name $CircuitName `
-ResourceGroupName $SourceResourceGroupName
 
Write-Host ‘Adding Authorisation’
# Add a authorisation request to the ExpressRoute Circuit
Add-AzureRmExpressRouteCircuitAuthorization `
-ExpressRouteCircuit $circuit `
-Name $AuthorisationName `
-Verbose
# Update the Circuit with the authorisation information
Set-AzureRmExpressRouteCircuit `
-ExpressRouteCircuit $circuit `
-Verbose
 
# Re-request information about the circuit
$circuit = Get-AzureRmExpressRouteCircuit `
-Name $CircuitName `
-ResourceGroupName $SourceResourceGroupName `
-Verbose
 
# Request information about the new authorisation
$auth1 = Get-AzureRmExpressRouteCircuitAuthorization `
-ExpressRouteCircuit $circuit `
-Name $AuthorisationName `
-Verbose
 
# Select Target Subscription
Select-AzureRmSubscription `
-SubscriptionName $TargetSubscriptionName
 
# Get information about the Target Gateway
$TargetGW = Get-AzureRmVirtualNetworkGateway `
-Name $TargetGatewayName `
-ResourceGroupName $TargetResourceGroupName
 
Write-Host ‘Redeeming Key’
 
$connection = New-AzureRmVirtualNetworkGatewayConnexion `
-Name $targetConnectionName `
-ResourceGroupName $TargetResourceGroupName `
-Location $TargetLocation `
-VirtualNetworkGateway1 $TargetGW `
-PeerId $Circuit.Id `
-ConnectionType ExpressRoute `
-AuthorizationKey $auth1.AuthorizationKey `
-Verbose

Connecting an Azure Express route circuit to another Virtual Network in a different subscription is relatively easy, but the process is not really well documented. The original documentation also specifies -circuit in many command lines instead of -ExpressRouteCircuit

It is also worth noting that (frustratingly) we cannot use a version 1 (Classic) circuit for this process. The two do not appear to be compatible.

Have more questions? Get in touch with Insentra today.

THANK YOU FOR YOUR SUBMISSION!

Australia | Connecting Virtual Networks in different Azure Subscriptions to an ExpressRoute Circuit in Resource Manager

The form was submitted successfully.

Join the Insentra Community with the Insentragram Newsletter

Hungry for more?

If you’re waiting for a sign, this is it.

We’re a certified amazing place to work, with an incredible team and fascinating projects – and we’re ready for you to join us! Go through our simple application process. Once you’re done, we will be in touch shortly!

Who is Insentra?

Imagine a business which exists to help IT Partners & Vendors grow and thrive.

Insentra is a 100% channel business. This means we provide a range of Advisory, Professional and Managed IT services exclusively for and through our Partners.

Our #PartnerObsessed business model achieves powerful results for our Partners and their Clients with our crew’s deep expertise and specialised knowledge.

We love what we do and are driven by a relentless determination to deliver exceptional service excellence.

Australia | Connecting Virtual Networks in different Azure Subscriptions to an ExpressRoute Circuit in Resource Manager

Insentra ISO 27001:2013 Certification

SYDNEY, WEDNESDAY 20TH APRIL 2022 – We are proud to announce that Insentra has achieved the  ISO 27001 Certification.