azure-cli-extensions icon indicating copy to clipboard operation
azure-cli-extensions copied to clipboard

Network Manager create/update does not support multiple subs/mgs

Open jbgorthy opened this issue 3 months ago • 1 comments

Describe the bug

Network Manager create/update does not support multiple subscriptions or management groups to be defined in the scope.

Related command

az network manager update --name jaredgorthy --resource-group jaredgorthy-testResources --network-manager-scopes management-groups="/providers/Microsoft.Management/managementGroups/alecolson_testmg1" management-groups="/providers/Microsoft.Management/managementGroups/alecolson_testmg1" "/providers/Microsoft.Management/managementGroups/alecolson_testmg2"

Errors

usage error: --network-manager-scopes [KEY=VALUE ...]

Issue script & Debug output

cli.knack.cli: Command arguments: ['network', 'manager', 'update', '--name', 'jaredgorthy', '--resource-group', 'jaredgorthy-testResources', '--network-manager-scopes', 'management-groups=/providers/Microsoft.Management/managementGroups/alecolson_testmg1', 'management-groups=/providers/Microsoft.Management/managementGroups/alecolson_testmg1', '/providers/Microsoft.Management/managementGroups/alecolson_testmg2', '--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 0x0212F938>, <function OutputProducer.on_global_arguments at 0x02258A28>, <function CLIQuery.on_global_arguments at 0x022787F8>] 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.811 115 454 cli.azure.cli.core: privatedns 0.050 14 60 cli.azure.cli.core: Total (2) 0.861 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.125 12 24 C:\Users\jaredgorthy.azure\cliextensions\virtual-network-manager cli.azure.cli.core: Total (1) 0.125 12 24 cli.azure.cli.core: Loaded 139 groups, 538 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : network manager update cli.azure.cli.core: Command table: network manager update cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x045605C8>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\jaredgorthy.azure\commands\2024-04-04.16-19-13.network_manager_update.61092.log'. az_command_data_logger: command args: network manager update --name {} --resource-group {} --network-manager-scopes {} {} {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x04590758>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x045CFA28>, <function register_cache_arguments..add_cache_arguments at 0x045CFA78>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.azure.cli.core.azclierror: Traceback (most recent call last): File "C:\Users\jaredgorthy.azure\cliextensions\virtual-network-manager\azext_network_manager\action.py", line 25, in get_action for (k, v) in (x.split('=', 1) for x in values): ^^^^^^ ValueError: not enough values to unpack (expected 2, got 1)

The above exception was the direct cause of the following exception:

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 589, in execute File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/parser.py", line 261, in parse_args File "argparse.py", line 1869, in parse_args File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 281, in parse_known_args File "argparse.py", line 1902, in parse_known_args File "argparse.py", line 2096, in _parse_known_args File "argparse.py", line 2073, in consume_positionals File "argparse.py", line 1978, in take_action File "argparse.py", line 1241, in call File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 281, in parse_known_args File "argparse.py", line 1902, in parse_known_args File "argparse.py", line 2096, in _parse_known_args File "argparse.py", line 2073, in consume_positionals File "argparse.py", line 1978, in take_action File "argparse.py", line 1241, in call File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 281, in parse_known_args File "argparse.py", line 1902, in parse_known_args File "argparse.py", line 2096, in _parse_known_args File "argparse.py", line 2073, in consume_positionals File "argparse.py", line 1978, in take_action File "argparse.py", line 1241, in call File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 281, in parse_known_args File "argparse.py", line 1902, in parse_known_args File "argparse.py", line 2114, in _parse_known_args File "argparse.py", line 2054, in consume_optional File "argparse.py", line 1978, in take_action File "C:\Users\jaredgorthy.azure\cliextensions\virtual-network-manager\azext_network_manager\action.py", line 19, in call action = self.get_action(values, option_string) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\jaredgorthy.azure\cliextensions\virtual-network-manager\azext_network_manager\action.py", line 29, in get_action raise CLIError(f'usage error: {option_string} [KEY=VALUE ...]') from exc knack.util.CLIError: usage error: --network-manager-scopes [KEY=VALUE ...]

cli.azure.cli.core.azclierror: usage error: --network-manager-scopes [KEY=VALUE ...] az_command_data_logger: usage error: --network-manager-scopes [KEY=VALUE ...] cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x04560708>] az_command_data_logger: exit code: 1 cli.main: Command ran in 2.308 seconds (init: 1.176, invoke: 1.132) 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 3449 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 should be able to define multiple subscriptions and management groups during the create/update of the network manager resources. For instance, a valid nm is

{ "name": "jaredgorthy", "location": "eastus", "properties": { "description": "", "networkManagerScopes": { "managementGroups": [ "/providers/Microsoft.Management/managementGroups/alecolson_testmg1", "/providers/Microsoft.Management/managementGroups/alecolson_testmg2" ], "subscriptions": [ "/subscriptions/2d56342a-7652-432b-87a5-56a180b17255", "/subscriptions/2d56342a-7652-432b-87a5-56a180b17345" ], }, "provisioningState": "Succeeded", "networkManagerScopeAccesses": [ "Connectivity", "SecurityAdmin" ], }, }

the customer needs to be able to pass in a list for both subs and mgs

--network-manager-scopes management-groups=[a,b,c] subscriptions=[a,b,c]

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

Additional context

No response

jbgorthy avatar Apr 04 '24 23:04 jbgorthy