Traiano Welcome
Traiano Welcome

Reputation: 846

Creating Azure ExpressRoute Connections via CLI: Error: ID was missing the expressRouteGateways element

I'm trying to create an azure expressroute connection using the Azure CLI, however there appears to be a discrepancy between the ExpressRoute Gateway Id as required by the API and the ExpresRoute Gateway ID as provided via the portal:

The portal provides the ER gw id as:

"/subscriptions/319b5c03-xxxxxxxxxx/resourceGroups/hk-connectivity-eastasia/providers/Microsoft.Network/virtualNetworkGateways/hk-ergw-eastasia"

However the azure cli seems to want:

"/subscriptions/319b5c03-xxxxxxxxxx/resourceGroups/hk-connectivity-eastasia/providers/Microsoft.Network/expressRouteGateways/hk-ergw-eastasia"

(or at least something containing "expressRouteGateways" )

So we get the error:

**az network express-route gateway connection create --gateway-name /subscriptions/REDACTED/resourceGroups/hk-connectivity-eastasia/providers/Microsoft.Network/virtualNetworkGateways/hk-ergw-eastasia --name hk-nprd-erc-000 --resource-group hk-connectivity-eastasia --circuit-name er-expressroute-ea-nprd-erc-hub00-net --peering AzurePrivatePeering


ERROR: (ResourceNotFound) 

The Resource 'Microsoft.Network/expressRouteGateways/subscriptions' 

under resource group 'hk-connectivity-eastasia' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

Code: ResourceNotFound

Message: The Resource 'Microsoft.Network/expressRouteGateways/subscriptions' under resource group 'hk-connectivity-eastasia' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
+ OUT=
+ printf 'connection creation result: \n'
connection creation result:

I can't seem to find this as a known bug or related issue though.

Attempt #2:

CLI:

az network express-route gateway connection create \
  --gateway-name hk-ergw-eastasia \ 
  --name hk-nonprod-erconn-000 \ 
  --peering /subscriptions/REDACTED/resourceGroups/hk-connectivity-eastasia/providers/Microsoft.Network/expressRouteCircuits/hk-nonprod/peerings/AzurePrivatePeering \
  --resource-group hk-connectivity-eastasia

Result:

++ az network express-route gateway connection create --gateway-name hk-ergw-eastasia --name hk-nonprod-erconn-000 --peering /subscriptions/REDACTED/resourceGroups/hk-connectivity-eastasia/providers/Microsoft.Network/expressRouteCircuits/hk-nonprod/peerings/AzurePrivatePeering --resource-group hk-connectivity-eastasia
ERROR: (ResourceNotFound) The Resource 'Microsoft.Network/expressRouteGateways/hk-ergw-eastasia' under resource group 'hk-connectivity-eastasia' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Code: ResourceNotFound
Message: The Resource 'Microsoft.Network/expressRouteGateways/hk-ergw-eastasia' under resource group 'hk-connectivity-eastasia' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

Troubleshooting notes:

  1. The ER Circuit is up and running
  2. BGP routes are being exchanged between the ISP and on-premises
  3. BGP routes to the Hub VNET and spoke VNETs attached to the ER gateway are being propagated to on-prem
  4. BGP peering is therefore fine.

Upvotes: 1

Views: 384

Answers (1)

Sourav
Sourav

Reputation: 1083

In order to create azure network express route to gateway connection, use below script.

You can get the Azure Gateway Name in Portal, like below.

Azure Portal > Virtual network gateways > Select your Gate Way

enter image description here

Here is the script to create a Azure ExpressRoute Connections

az network express-route gateway connection create --gateway-name MyGateway --name MyExpressRouteConnection --peering /subscriptions/MySub/resourceGroups/MyResourceGroup/provi ders/Microsoft.Network/expressRouteCircuits/MyCircuit/peerings/AzurePrivatePeering --resource-group MyResourceGroup

Reference: https://learn.microsoft.com/en-us/cli/azure/network/express-route/gateway/connection?view=azure-cli-latest#az-network-express-route-gateway-connection-create

Upvotes: 0

Related Questions