Azure / azure-cli-extensions

Public Repository for Extensions of Azure CLI.
https://docs.microsoft.com/en-us/cli/azure
MIT License
374 stars 1.16k forks source link

Connectivity Configuration Conditional Required Param - virtual-network-manager #7301

Open jbgorthy opened 4 months ago

jbgorthy commented 4 months ago

Describe the bug

For command az network manager connect-config create, the required parameters are conditional to the 'connectivity-topology' the user selects. If the user selects --connectivity-topology Mesh, then 'group-connectivity' should not be required within 'applies-to-groups'. Currently, it is required. Please only make it required if user defines --connectivity-topology HubAndSpoke

Related command

az network manager connect-config create

Errors

az network manager connect-config create --network-manager-name jaredgorthy --resource-group jaredgorthy-testResources --configuration-name cliCreate221 --applies-to-groups network-group-id="/subscriptions/f0dc2b34-dfad-40e4-83e0-2309fed8d00b/resourceGroups/jaredgorthy-testResources/providers/Microsoft.Network/networkManagers/jaredgorthy/networkGroups/CLIWorks" --connectivity-topology Mesh

Error is

InvalidArgumentValue: --applies-to-groups[0]: Missing required field: group-connectivity

Issue script & Debug output

C:\Users\jaredgorthy>az network manager connect-config create --network-manager-name jaredgorthy --resource-group jaredgorthy-testResources --configuration-name cliCreate221 --applies-to-groups network-group-id="/subscriptions/f0dc2b34-dfad-40e4-83e0-2309fed8d00b/resourceGroups/jaredgorthy-testResources/providers/Microsoft.Network/networkManagers/jaredgorthy/networkGroups/CLIWorks" --connectivity-topology Mesh --debug cli.knack.cli: Command arguments: ['network', 'manager', 'connect-config', 'create', '--network-manager-name', 'jaredgorthy', '--resource-group', 'jaredgorthy-testResources', '--configuration-name', 'cliCreate221', '--applies-to-groups', 'network-group-id=/subscriptions/f0dc2b34-dfad-40e4-83e0-2309fed8d00b/resourceGroups/jaredgorthy-testResources/providers/Microsoft.Network/networkManagers/jaredgorthy/networkGroups/CLIWorks', '--connectivity-topology', 'Mesh', '--debug'] cli.knack.cli: init debug log: Enable color in terminal. Enable VT mode. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x01EDF8E8>, <function OutputProducer.on_global_arguments at 0x020059D8>, <function CLIQuery.on_global_arguments at 0x022297A8>] 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_network_manager'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: network 0.545 115 454 cli.azure.cli.core: privatedns 0.057 14 60 cli.azure.cli.core: Total (2) 0.602 129 514 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: virtual-network-manager 0.105 12 28 C:\Users\jaredgorthy.azure\cliextensions\virtual-network-manager cli.azure.cli.core: Total (1) 0.105 12 28 cli.azure.cli.core: Loaded 139 groups, 542 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : network manager connect-config create cli.azure.cli.core: Command table: network manager connect-config create cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x04321438>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\jaredgorthy.azure\commands\2024-02-21.14-36-35.network_manager_connect-config_create.6884.log'. az_command_data_logger: command args: network manager connect-config create --network-manager-name {} --resource-group {} --configuration-name {} --applies-to-groups {} --connectivity-topology {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x0434F5C8>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x0438F898>, <function register_cache_arguments..add_cache_arguments at 0x0438F8E8>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x02005A28>, <function CLIQuery.handle_query_parameter at 0x022297F8>, <function register_ids_argument..parse_ids_arguments at 0x0438F848>] az_command_data_logger: extension name: virtual-network-manager az_command_data_logger: extension version: 1.0.1 cli.azure.cli.core.azclierror: Traceback (most recent call last): File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command_ctx.py", line 53, in format_args File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_arg_fmt.py", line 402, in call File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_arg_fmt.py", line 399, in call File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_arg_fmt.py", line 519, in call File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_arg_fmt.py", line 516, in call File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_arg_fmt.py", line 415, in call azure.cli.core.aaz.exceptions.AAZInvalidArgValueError: InvalidArgumentValue: --applies-to-groups[0]: Missing required field: group-connectivity

During handling of the above exception, another exception occurred:

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 729, 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 698, in _run_job File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 334, in call File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler File "C:\Users\jaredgorthy.azure\cliextensions\virtual-network-manager\azext_network_manager\custom.py", line 96, in network_manager_connect_config_create return ConnectConfigCreate(cli_ctx=cmd.cli_ctx)(command_args=connectivity_configuration) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command.py", line 155, in call File "C:\Users\jaredgorthy.azure\cliextensions\virtual-network-manager\azext_network_manager\aaz\latest\network\manager\connect_config_create.py", line 32, in _handler super()._handler(command_args) File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command.py", line 165, in _handler File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command_ctx.py", line 55, in format_args azure.cli.core.azclierror.InvalidArgumentValueError: InvalidArgumentValue: --applies-to-groups[0]: Missing required field: group-connectivity

cli.azure.cli.core.azclierror: InvalidArgumentValue: --applies-to-groups[0]: Missing required field: group-connectivity az_command_data_logger: InvalidArgumentValue: --applies-to-groups[0]: Missing required field: group-connectivity cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x04321578>] az_command_data_logger: exit code: 1 cli.main: Command ran in 1.546 seconds (init: 0.741, invoke: 0.805) cli.azure.cli.core.decorators: Suppress exception: Traceback (most recent call last): File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/main.py", line 62, in File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/main.py", line 55, in SystemExit: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/decorators.py", line 79, in _wrapped_func File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/telemetry.py", line 532, in _get_secrets_warning_config File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/config.py", line 147, in getboolean ValueError: Not a boolean: None

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 3705 in cache telemetry.main: Begin creating telemetry upload process. telemetry.process: Creating upload process: "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry__init__.pyc C:\Users\jaredgorthy.azure" telemetry.process: Return from creating process telemetry.main: Finish creating telemetry upload process.

Expected behavior

I expect to not have to define the 'group-connectivity' when the topology is a Mesh.

Environment Summary

azure-cli 2.57.0

core 2.57.0 telemetry 1.1.0

Extensions: account 0.2.5 azure-devops 0.26.0 virtual-network-manager 1.0.1

Dependencies: msal 1.26.0 azure-mgmt-resource 23.1.0b2

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Users\jaredgorthy.azure\cliextensions' Development extension sources: C:\CLI_test\azure-cli-extensions

Python (Windows) 3.11.7 (tags/v3.11.7:fa7a6f2, Dec 4 2023, 19:13:08) [MSC v.1937 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 4 months ago

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