Azure / azure-cli

Azure Command-Line Interface
MIT License
3.97k stars 2.95k forks source link

az keyvault role assignment create is failing with please specify --hsm-name or --id #28130

Open dileepyavan opened 8 months ago

dileepyavan commented 8 months ago

Describe the bug

Trying to create a role assignment as below:

MicrosoftTeams-image

Related command

az keyvault role assignment create

Errors

Please specify --hsa-name or --id

Issue script & Debug output

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 0x7f01b10131f0>, <function OutputProducer.on_global_arguments at 0x7f01b0f2ed30>, <function CLIQuery.on_global_arguments at 0x7f01b0ec6310>] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'keyvault': ['azure.cli.command_modules.keyvault'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: keyvault 0.013 20 113 cli.azure.cli.core: Total (1) 0.013 20 113 cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_next'] cli.azure.cli.core: Loading extensions: cli.azure.cli.core: Name Load Time Groups Commands Directory cli.azure.cli.core: ai-examples 0.132 1 1 /usr/lib/python3.9/site-packages/azure-cli-extensions/ai-examples cli.azure.cli.core: Total (1) 0.132 1 1
cli.azure.cli.core: Loaded 21 groups, 114 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : keyvault role assignment create cli.azure.cli.core: Command table: keyvault role assignment create cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7f01b036a3a0>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/dileep/.azure/commands/2024-01-04.00-02-35.keyvault_role_assignment_create.2551.log'. az_command_data_logger: command args: keyvault role assignment create --role {} --assignee-object-id {} --scope {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x7f01b0310f70>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x7f01b02fc040>, <function register_cache_arguments..add_cache_arguments at 0x7f01b0306e50>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7f01b0f2edc0>, <function CLIQuery.handle_query_parameter at 0x7f01b0ec63a0>, <function register_ids_argument..parse_ids_arguments at 0x7f01b0306dc0>] cli.azure.cli.core.azclierror: Traceback (most recent call last): File "/usr/lib64/az/lib/python3.9/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 651, in execute self._validation(expanded_arg) File "/usr/lib64/az/lib/python3.9/site-packages/knack/invocation.py", line 113, in _validation self._validate_arg_level(parsed_ns) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 859, in _validate_arg_level validator(**self._build_kwargs(validator, ns)) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/keyvault/_validators.py", line 192, in process_hsm_name raise CLIError('Please specify --hsm-name or --id.') knack.util.CLIError: Please specify --hsm-name or --id.

cli.azure.cli.core.azclierror: Please specify --hsm-name or --id. az_command_data_logger: Please specify --hsm-name or --id. cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f01b036a5e0>] az_command_data_logger: exit code: 1 cli.main: Command ran in 0.515 seconds (init: 0.148, invoke: 0.367) 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 3566 in cache telemetry.main: Begin creating telemetry upload process. telemetry.process: Creating upload process: "/usr/bin/python3.9 /usr/lib/az/lib/python3.9/site-packages/azure/cli/telemetry/init.py /home/dileep/.azure" telemetry.process: Return from creating process telemetry.main: Finish creating telemetry upload process.

Expected behavior

role assignmnet should be created. With the same arguments az powershell is working as expected.

Environment Summary

azure-cli 2.55.0

core 2.55.0 telemetry 1.1.0

Extensions: ai-examples 0.2.5 azure-cli-ml 1.41.0 ml 2.22.0 ssh 2.0.2 storage-preview 0.8.3

Dependencies: msal 1.24.0b2 azure-mgmt-resource 23.1.0b2

Python location '/usr/bin/python3.9' Extensions directory '/home/dileep/.azure/cliextensions' Extensions system directory '/usr/lib/python3.9/site-packages/azure-cli-extensions'

Python (Linux) 3.9.14 (main, Oct 12 2023, 19:48:32) [GCC 11.2.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 8 months ago

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

evelyn-ys commented 8 months ago

Hi @dileepyavan, az keyvault role assignment create is used for Mnagaed HSM resources and the scope parameter takes values like / or /keys or similar.

Probably you want to use az role assignment create for your scenario? See https://learn.microsoft.com/en-us/cli/azure/role/assignment?view=azure-cli-latest#az-role-assignment-create