通过Azure CLI创建ExpressRoute连接报错:ID缺少expressRouteGateways元素
Azure CLI创建ExpressRoute连接时网关ID不匹配导致资源找不到错误
问题核心
使用Azure CLI创建ExpressRoute连接时,发现API要求的ExpressRoute网关ID与Azure门户提供的存在格式差异:
- 门户提供的ER网关ID:
"/subscriptions/319b5c03-xxxxxxxxxx/resourceGroups/hk-connectivity-eastasia/providers/Microsoft.Network/virtualNetworkGateways/hk-ergw-eastasia"
- Azure CLI命令似乎要求ID包含
expressRouteGateways路径:
"/subscriptions/319b5c03-xxxxxxxxxx/resourceGroups/hk-connectivity-eastasia/providers/Microsoft.Network/expressRouteGateways/hk-ergw-eastasia"
第一次尝试及错误输出
执行命令:
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 refer to official ARM resource troubleshooting guidance. Code: ResourceNotFound Message: The Resource 'Microsoft.Network/expressRouteGateways/subscriptions' under resource group 'hk-connectivity-eastasia' was not found. For more details please refer to official ARM resource troubleshooting guidance. + OUT= + printf 'connection creation result: \n' connection creation result:
未找到该问题相关的已知Bug或公开案例。
第二次尝试及错误输出
执行命令:
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
返回错误:
++ 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 refer to official ARM resource troubleshooting guidance. Code: ResourceNotFound Message: The Resource 'Microsoft.Network/expressRouteGateways/hk-ergw-eastasia' under resource group 'hk-connectivity-eastasia' was not found. For more details please refer to official ARM resource troubleshooting guidance.
已完成的故障排查项
- ER线路运行正常
- ISP与本地环境已成功交换BGP路由
- 通往Hub VNET及ER网关关联的Spoke VNET的BGP路由已传播至本地网络
- BGP对等互联状态正常
内容的提问来源于stack exchange,提问作者Traiano Welcome
相关产品推荐
相关产品推荐

