Azure / azure-cli

Azure Command-Line Interface
MIT License
3.95k stars 2.93k forks source link

az tag command doesn't support space in tag value or name in Azure cli Windows editon. #28861

Open henryzhan2020 opened 4 months ago

henryzhan2020 commented 4 months ago

Describe the bug

Based on below doc, it should work: https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources-cli#handling-spaces

Validated it's working for Linux Azure cli but not for Windows Azure cli:

image

Related command

az tag update

Errors

(InvalidTagName) The tag name must be non-null, non-empty and non-whitespace only. Please provide an actual value. Code: InvalidTagName Message: The tag name must be non-null, non-empty and non-whitespace only. Please provide an actual value.

Issue script & Debug output

cli.azure.cli.core.sdk.policies: {"error":{"code":"InvalidTagName","message":"The tag name must be non-null, non-empty and non-whitespace only. Please provide an actual value."}} 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 701, 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 "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 4112, in update_tag_at_scope 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/mgmt/resource/resources/v2022_09_01/operations/_operations.py", line 12859, in begin_update_at_scope File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/resource/resources/v2022_09_01/operations/_operations.py", line 12723, in _update_at_scope_initial azure.core.exceptions.HttpResponseError: (InvalidTagName) The tag name must be non-null, non-empty and non-whitespace only. Please provide an actual value. Code: InvalidTagName Message: The tag name must be non-null, non-empty and non-whitespace only. Please provide an actual value.

cli.azure.cli.core.azclierror: (InvalidTagName) The tag name must be non-null, non-empty and non-whitespace only. Please provide an actual value. Code: InvalidTagName Message: The tag name must be non-null, non-empty and non-whitespace only. Please provide an actual value. az_command_data_logger: (InvalidTagName) The tag name must be non-null, non-empty and non-whitespace only. Please provide an actual value. Code: InvalidTagName Message: The tag name must be non-null, non-empty and non-whitespace only. Please provide an actual value. cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x000001D89E8E22A0>]

Expected behavior

same as Linux Azure cli

Environment Summary

{ "azure-cli": "2.60.0", "azure-cli-core": "2.60.0", "azure-cli-telemetry": "1.1.0", "extensions": {} }

Additional context

No response

yonzhan commented 4 months ago

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

microsoft-github-policy-service[bot] commented 4 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @josephkwchan, @jennyhunter-msft.

havlicekp commented 1 month ago

This works for me - please note that both the tag name and value are in quotes:

--tags "Some tag with spaces=value"

I also experience the error when the tag name and value are separated. This does not work:

--tags "Some tag with spaces"="value"