Azure / azure-cli

Azure Command-Line Interface
MIT License
3.96k stars 2.94k forks source link

Creating ExpressRoute Gateway Connection not working in CLI, but it's working through ARM template deployment #29102

Open husamhilal opened 3 months ago

husamhilal commented 3 months ago

Describe the bug

Creating ExpressRoute Gateway Connection not working in CLI, but it's working through ARM template deployment.

az network express-route gateway connection create --gateway-name $erGateway -n $erConnection -g $netRG --peering $avsERPeering

It's complaining that subscription provided in the $avsERPeering is not available.

Subscription 'xyz' not found. Check the spelling and casing and try again.

Consider that I'm setting up the ER GW Connection from a different subscription of where I have the ER Circuit.

It is working fine when I deploy from the portal, or ARM template, but keeps failing in CLI.

Any help will be appreciaited 😊

Related command

az network express-route gateway connection create --gateway-name $erGateway -n $erConnection -g $netRG --peering $avsERPeering

Errors

I replaced the actual subscription Id with "xyx"

Subscription 'xyz' not found. Check the spelling and casing and try again.

Issue script & Debug output

I replaced the actual subscription Id with "xyx" and user account with "abc"

az network express-route gateway connection create --gateway-name $erGateway -n $erConnection -g $netRG --peering /subscriptions/xyz/resourceGroups/tnt35-cust-p02-canadacentral/providers/Microsoft.Network/expressRouteCircuits/tnt35-cust-p02-canadacentral-er/peerings/AzurePrivatePeering --debug cli.knack.cli: Command arguments: ['network', 'express-route', 'gateway', 'connection', 'create', '--gateway-name', 'LAB-AVS-ER-GW', '-n', 'LAB-AVS-ER-Connection', '-g', 'Lab-Network-RG', '--peering', '/subscriptions/xyz/resourceGroups/tnt35-cust-p02-canadacentral/providers/Microsoft.Network/expressRouteCircuits/tnt35-cust-p02-canadacentral-er/peerings/AzurePrivatePeering', '--debug'] cli.knack.cli: init debug log: Enable color in terminal. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x000001382646B880>, <function OutputProducer.on_global_arguments at 0x00000138265F60C0>, <function CLIQuery.on_global_arguments at 0x0000013826623C40>] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'network': ['azure.cli.command_modules.network', 'azure.cli.command_modules.privatedns', 'azext_bastion'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: network 0.439 116 476 cli.azure.cli.core: privatedns 0.026 14 60 cli.azure.cli.core: Total (2) 0.465 130 536 cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next'] cli.azure.cli.core: Loading extensions: cli.azure.cli.core: Name Load Time Groups Commands Directory cli.azure.cli.core: bastion 0.014 2 4 C:\Users\abc.azure\cliextensions\bastion cli.azure.cli.core: Total (1) 0.014 2 4 cli.azure.cli.core: Loaded 130 groups, 540 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : network express-route gateway connection create cli.azure.cli.core: Command table: network express-route gateway connection create cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x000001382949E340>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\abc.azure\commands\2024-06-05.11-42-11.network_express-route_gateway_connection_create.28332.log'. az_command_data_logger: command args: network express-route gateway connection create --gateway-name {} -n {} -g {} --peering {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x0000013829504860>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x0000013829504900>, <function register_cache_arguments..add_cache_arguments at 0x0000013829504A40>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x00000138265F6160>, <function CLIQuery.handle_query_parameter at 0x0000013826623CE0>, <function register_ids_argument..parse_ids_arguments at 0x00000138295049A0>] Command group 'az network' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus cli.azure.cli.core.azclierror: Traceback (most recent call last): File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 664, in execute File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 731, in _run_jobs_serially File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 712, in _run_job File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 1039, in call File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_poller.py", line 108, in result File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/core/tracing/decorator.py", line 76, in wrapper_use_tracer File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_poller.py", line 130, in wait File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_poller.py", line 83, in _start File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\command_modules\network\aaz_compact\latest\network\express_route\gateway\connection__cmds.py", line 165, in _execute_operations File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_operation.py", line 42, in init File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command_ctx.py", line 73, in get_http_client File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command_ctx.py", line 58, in get_login_credential File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/_profile.py", line 353, in get_login_credentials File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/_profile.py", line 576, in get_subscription knack.util.CLIError: Subscription 'xyz' not found. Check the spelling and casing and try again.

cli.azure.cli.core.azclierror: Subscription 'xyz' not found. Check the spelling and casing and try again. az_command_data_logger: Subscription 'xyz' not found. Check the spelling and casing and try again. cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x000001382949E5C0>] az_command_data_logger: exit code: 1 cli.main: Command ran in 1.085 seconds (init: 0.502, invoke: 0.583) telemetry.main: Begin splitting cli events and extra events, total events: 1 telemetry.client: Accumulated 0 events. Flush the clients. telemetry.main: Finish splitting cli events and extra events, cli events: 1 telemetry.save: Save telemetry record of length 3876 in cache telemetry.main: Begin creating telemetry upload process. telemetry.process: Creating upload process: "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry__init__.pyc C:\Users\abc.azure" telemetry.process: Return from creating process telemetry.main: Finish creating telemetry upload process.

Expected behavior

Create the ER GW Connection.

Environment Summary

azure-cli 2.61.0

core 2.61.0 telemetry 1.1.0

Extensions: account 0.2.5 bastion 0.3.0 connectedvmware 1.0.1 dns-resolver 0.2.0 resource-graph 2.1.0 vmware 6.0.1

Dependencies: msal 1.28.0 azure-mgmt-resource 23.1.1

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Users\huhilal.azure\cliextensions'

Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 3 months ago

Thank you for opening this issue, we will look into it.

husamhilal commented 3 months ago

Thank you for opening this issue, we will look into it.

Thanks a lot @yonzhan! I'm internal in Microsoft, feel free to reach out and I can share screen with you.

husamhilal commented 3 months ago

@yonzhan have this been identified as an issue? I see it's been added to Backlog. Is there any timeline to fix this issue? Thanks!

husamhilal commented 3 months ago

@yonzhan I noticed that the command fails even if the ER GW and ER Circuit are in the same subscription. Please advise.

necusjz commented 3 months ago

@husamhilal could you please try az cloud set --name AzureCloud --profile latest? then execute the above commands, since the below line is weird.

Command group 'az network' is in preview and under development.

husamhilal commented 2 months ago

thanks @necusjz I will test and let you know ;)

husamhilal commented 2 months ago

@necusjz I tried, but got the same error.

I also verified that by re-installing Azure CLI to make sure it's not just a local issue. And ran az version so I can share with you if needed.

az version
{
  "azure-cli": "2.61.0",
  "azure-cli-core": "2.61.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {
    "account": "0.2.5",
    "bastion": "0.3.0",
    "connectedvmware": "1.1.0",
    "dns-resolver": "0.2.0",
    "resource-graph": "2.1.0",
    "vmware": "6.0.1"
  }
}
necusjz commented 2 months ago

i see, may i know the entire scripts? Including az network express-route create, az network express-route gateway create or az network express-route peering create.

husamhilal commented 2 months ago

i see, may i know the entire scripts? Including az network express-route create, az network express-route gateway create or az network express-route peering create.

az network vnet-gateway create --name $erGateway --resource-group $networkRG --location $location --gateway-type ExpressRoute --sku Standard --public-ip-addresses $erGatewayIP --vnet $vNetName --no-wait

$avsERPeering = az vmware private-cloud show --name $avsPCName --resource-group $avsRG --query "circuit.expressRoutePrivatePeeringID" -o tsv

$avsERPeeringAuthkey = az vmware authorization create --authorization-name $avsERPeeringAuthkeyName --private-cloud $avsPCName --resource-group $avsRG --query "expressRouteAuthorizationKey" -o tsv

az network express-route gateway connection create --name $erConnection --gateway-name $erGateway --resource-group $networkRG --peering $avsERPeering --authorization-key $avsERPeeringAuthkey --no-wait
husamhilal commented 1 month ago

any updates? @necusjz @yonzhan