Quickstart: Create an ExpressRoute circuit with private peering using Bicep
Article
This quickstart describes how to use Bicep to create an ExpressRoute circuit with private peering.
Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure.
Prerequisites
If you don't have an Azure subscription, create a free account before you begin.
In this quickstart, you create an ExpressRoute circuit with Equinix as the service provider. The circuit is using a Premium SKU, with a bandwidth of 50 Mbps, and the peering location of Washington DC. Private peering is enabled with a primary and secondary subnet of 192.168.10.16/30 and 192.168.10.20/30 respectively. A virtual network gets created along with a HighPerformance ExpressRoute gateway.
Bicep
@description('Location for all resources deployed in the Bicep file')paramlocationstring = resourceGroup().location
@description('ExpressRoute peering location')paramerpeeringLocationstring = 'Washington DC'
@description('Name of the ExpressRoute circuit')paramerCircuitNamestring = 'er-ckt01'
@description('Name of the ExpressRoute provider')paramserviceProviderNamestring = 'Equinix'
@description('Tier ExpressRoute circuit')
@allowed([
'Premium''Standard'
])paramerSKU_Tierstring = 'Premium'
@description('Billing model ExpressRoute circuit')
@allowed([
'MeteredData''UnlimitedData'
])paramerSKU_Familystring = 'MeteredData'
@description('Bandwidth ExpressRoute circuit')
@allowed([
5010020050010002000500010000
])parambandwidthInMbpsint = 50
@description('autonomous system number used to create private peering between the customer edge router and MSEE routers')parampeerASNint = 65001
@description('point-to-point network prefix of primary link between the customer edge router and MSEE router')paramprimaryPeerAddressPrefixstring = '192.168.10.16/30'
@description('point-to-point network prefix of secondary link between the customer edge router and MSEE router')paramsecondaryPeerAddressPrefixstring = '192.168.10.20/30'
@description('VLAN Id used between the customer edge routers and MSEE routers. primary and secondary link have the same VLAN Id')paramvlanIdint = 100
@description('name of the Virtual Network')paramvnetNamestring = 'vnet1'
@description('name of the subnet')paramsubnet1Namestring = 'subnet1'
@description('address space assigned to the Virtual Network')paramvnetAddressSpacestring = '10.10.10.0/24'
@description('network prefix assigned to the subnet')paramsubnet1Prefixstring = '10.10.10.0/25'
@description('network prefixes assigned to the gateway subnet. It has to be a network prefix with mask /27 or larger')paramgatewaySubnetPrefixstring = '10.10.10.224/27'
@description('name of the ExpressRoute Gateway')paramgatewayNamestring = 'er-gw'
@description('ExpressRoute Gateway SKU')
@allowed([
'Standard''HighPerformance''UltraPerformance''ErGw1AZ''ErGw2AZ''ErGw3AZ'
])paramgatewaySkustring = 'HighPerformance'varerSKU_Name = '${erSKU_Tier}_${erSKU_Family}'vargatewayPublicIPName = '${gatewayName}-pubIP'varnsgName = 'nsg'resourceerCircuit'Microsoft.Network/expressRouteCircuits@2023-09-01' = {
name: erCircuitNamelocation: locationsku: {
name: erSKU_Nametier: erSKU_Tierfamily: erSKU_Family
}
properties: {
serviceProviderProperties: {
serviceProviderName: serviceProviderNamepeeringLocation: erpeeringLocationbandwidthInMbps: bandwidthInMbps
}
allowClassicOperations: false
}
}
resourcepeering'Microsoft.Network/expressRouteCircuits/peerings@2023-09-01' = {
parent: erCircuitname: 'AzurePrivatePeering'properties: {
peeringType: 'AzurePrivatePeering'peerASN: peerASNprimaryPeerAddressPrefix: primaryPeerAddressPrefixsecondaryPeerAddressPrefix: secondaryPeerAddressPrefixvlanId: vlanId
}
}
resourcensg'Microsoft.Network/networkSecurityGroups@2023-09-01' = {
name: nsgNamelocation: locationproperties: {
securityRules: [
{
name: 'SSH-rule'properties: {
description: 'allow SSH'protocol: 'Tcp'sourcePortRange: '*'destinationPortRange: '22'sourceAddressPrefix: '*'destinationAddressPrefix: 'VirtualNetwork'access: 'Allow'priority: 500direction: 'Inbound'
}
}
{
name: 'RDP-rule'properties: {
description: 'allow RDP'protocol: 'Tcp'sourcePortRange: '*'destinationPortRange: '3389'sourceAddressPrefix: '*'destinationAddressPrefix: 'VirtualNetwork'access: 'Allow'priority: 600direction: 'Inbound'
}
}
]
}
}
resourcevnet'Microsoft.Network/virtualNetworks@2023-09-01' = {
name: vnetNamelocation: locationproperties: {
addressSpace: {
addressPrefixes: [
vnetAddressSpace
]
}
subnets: [
{
name: subnet1Nameproperties: {
addressPrefix: subnet1PrefixnetworkSecurityGroup: {
id: nsg.id
}
}
}
{
name: 'GatewaySubnet'properties: {
addressPrefix: gatewaySubnetPrefix
}
}
]
}
}
resourcegatewayPublicIP'Microsoft.Network/publicIPAddresses@2023-09-01' = {
name: gatewayPublicIPNamelocation: locationsku: {
name: 'Standard'tier: 'Regional'
}
properties: {
publicIPAllocationMethod: 'Static'
}
}
resourcegateway'Microsoft.Network/virtualNetworkGateways@2023-09-01' = {
name: gatewayNamelocation: locationproperties: {
ipConfigurations: [
{
properties: {
privateIPAllocationMethod: 'Dynamic'subnet: {
id: resourceId('Microsoft.Network/virtualNetworks/subnets', vnetName, 'GatewaySubnet')
}
publicIPAddress: {
id: gatewayPublicIP.id
}
}
name: 'gwIPconf'
}
]
gatewayType: 'ExpressRoute'sku: {
name: gatewaySkutier: gatewaySku
}
vpnType: 'RouteBased'
}
dependsOn: [
vnet
]
}
outputerCircuitNamestring = erCircuitNameoutputgatewayNamestring = gatewayNameoutputgatewaySkustring = gatewaySku
Multiple Azure resources have been defined in the Bicep file:
In this quickstart, you create a resource group, a virtual network, a subnet for the gateway, a public IP for the gateway, an Azure ExpressRoute gateway, an ExpressRoute circuit, and an ExpressRoute circuit peering in Azure.
This article shows you how to create and provision the private, public, and Microsoft peering of an ExpressRoute circuit. This article also shows you how to check the status, update, or delete peerings for your circuit.
This article shows you how to evaluate the resiliency of your ExpressRoute circuit deployment by manually testing the failover of your ExpressRoute circuits.