Repository navigation
az policy assignment show - error after upgrade to version 2.77 #32159
Description
Describe the bug
az policy assignment show - errors are shwon after upgrade to version 2.77
az policy assignment show --name "ALZ-Policy-v1.0.0" --scope '/providers/Microsoft.Management/managementGroups/ALZ'
InvalidArgumentValue: -n: Invalid format: 'ALZ-Policy-v1.0.0' does not fully match regular expression pattern '^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$'
Related command
az policy assignment show --name "ALZ-Policy-v1.0.0" --scope '/providers/Microsoft.Management/managementGroups/ALZ'
Errors
InvalidArgumentValue: -n: Invalid format: 'ALZ-Policy-v1.0.0' does not fully match regular expression pattern '^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$'
Issue script & Debug output
az policy assignment show --name "ALZ-Policy-v1.0.0" --scope '/providers/Microsoft.Management/managementGroups/ALZ' --debug
cli.knack.cli: Command arguments: ['policy', 'assignment', 'show', '--name', 'ALZ-Policy-v1.0.0', '--scope', '/providers/Microsoft.Management/managementGroups/ALZ', '--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 0x000001C75E6244A0>, <function OutputProducer.on_global_arguments at 0x000001C75EBB98A0>, <function CLIQuery.on_global_arguments at 0x000001C75EC0B7E0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'policy': ['azure.cli.command_modules.policyinsights', 'azure.cli.command_modules.resource']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: policyinsights 0.478 9 17
cli.azure.cli.core: resource 0.100 52 234
cli.azure.cli.core: Total (2) 0.578 61 251
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: Total (0) 0.000 0 0
cli.azure.cli.core: Loaded 60 groups, 251 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : policy assignment show
cli.azure.cli.core: Command table: policy assignment show
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x000001C760B7D080>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\twiktorowicz.azure\commands\2025-09-23.11-41-46.policy_assignment_show.18276.log'.
az_command_data_logger: command args: policy assignment show --name {} --scope {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x000001C7613C25C0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x000001C7614F4900>, <function register_cache_arguments..add_cache_arguments at 0x000001C7614F4AE0>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x000001C7614F4B80>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x000001C75EBB9940>, <function CLIQuery.handle_query_parameter at 0x000001C75EC0B880>, <function register_ids_argument..parse_ids_arguments at 0x000001C7614F49A0>]
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 56, in call
azure.cli.core.aaz.exceptions.AAZInvalidArgValueError: InvalidArgumentValue: -n: Invalid format: 'ALZ-Policy-v1.0.0' does not fully match regular expression pattern '^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$'
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 666, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 734, 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 703, in _run_job
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 "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/aaz/latest/policy/assignment/_show.py", line 34, in _handler
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: -n: Invalid format: 'ALZ-Policy-v1.0.0' does not fully match regular expression pattern '^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$'
cli.azure.cli.core.azclierror: InvalidArgumentValue: -n: Invalid format: 'ALZ-Policy-v1.0.0' does not fully match regular expression pattern '^[^<>*%&:\?.+/][^<>*%&:\?.+/ ]+$'
az_command_data_logger: InvalidArgumentValue: -n: Invalid format: 'ALZ-Policy-v1.0.0' does not fully match regular expression pattern '^[^<>*%&:\?.+/][^<>*%&:\?.+/ ]+$'
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x000001C760B7D300>]
az_command_data_logger: exit code: 1
cli.main: Command ran in 1.179 seconds (init: 0.372, invoke: 0.807)
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 3948 in cache file under C:\Users\twiktorowicz.azure\telemetry\20250923114146706
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\twiktorowicz.azure C:\Users\twiktorowicz.azure\telemetry\20250923114146706"
telemetry.process: Return from creating process 29212
telemetry.main: Finish creating telemetry upload process.
Expected behavior
It should just show policy assignment with a given name.
It was working before using version 2.76
Environment Summary
azure-cli 2.77.0
core 2.77.0
telemetry 1.1.0
Extensions:
application-insights 1.2.3
azure-devops 1.0.2
connectedmachine 2.0.0b1
log-analytics 1.0.0b1
monitor-control-service 1.2.0
portal Unknown
resource-graph Unknown
scheduled-query 1.0.0b1
stack-hci 1.1.0
stack-hci-vm 1.10.4
Dependencies:
msal 1.34.0b1
azure-mgmt-resource 23.3.0
Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Config directory 'C:\Users\twiktorowicz.azure'
Extensions directory 'C:\Users\twiktorowicz.azure\cliextensions'
Python (Windows) 3.13.7 (tags/v3.13.7:bcee1c3, Aug 14 2025, 14:15:11) [MSC v.1944 64 bit (AMD64)]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Additional context
It was tested locally on Windows 11 laptop, but the same errors are showing when using MS Hosted agents in Azure DevOps pipelines executed on ubuntu-latest image.
Activity
yonzhan commentedon Sep 23, 2025
Thank you for opening this issue, we will look into it.
twiktorowicz commentedon Feb 17, 2026
Hi Team. Do you have any updates after a few months of reporting this issue? @aperezcloud kenieva-MSFT (@kenieva)?
Celinadhh commentedon May 20, 2026
Hi, Policy team has identified the issue and are working on a fix. Will update this thread with ETA when we get a better grasp.
azclibot commentedon Jun 22, 2026
Bug Analysis
Issue:
az policy assignmentcommands reject names containing dots (e.g.ALZ-Policy-v1.0.0) with a regex validation error since CLI version 2.77. This is a regression from v2.76.Root cause: The AAZ-generated argument formatter in
azure/cli/command_modules/resource/aaz/latest/policy/assignment/validates the--name(-n) argument against the pattern^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$. This character class unintentionally includes.(dot) in the forbidden set, but Azure Policy allows dots in assignment names (e.g.ALZ-Policy-v1.0.0).Failing command:
Error:
Fix needed: Update the regex pattern for the
--nameargument in allaz policy assignmentsubcommands (show, delete, list, create, etc.) underazure/cli/command_modules/resource/aaz/latest/policy/assignment/to allow dots. Remove.from the forbidden character set in the regex, or use the pattern that was effective in v2.76.Also check
az policy set-definition,az policy definition, andaz policy exemptioncommands for the same pattern, and fix those too if affected.Expected behavior:
az policy assignment show --name "ALZ-Policy-v1.0.0" --scope ...should succeed (as it did in v2.76).PR title & description format (required)
This repo enforces a PR format (guide). Please author the PR exactly as follows or CI's Check the Format of Pull Request Title and Content will fail.
Title
[Resource]— square brackets[]for a customer-facing change (added toHISTORY.rst), curly{}if not. A bug fix is customer-facing, so use[].Fix #32159:to link the issue.az <command>:.[Resource] Fix #32159: az <command>: Fix <concise description of the fix>Description — follow the PR template and fill in:
Fixes #32159.az ...command this affects.[Resource] az <command>: <note>lines for extra notes.Posted by agent-assist (autonomous bug-fix pipeline).
[Resource] Fix #32159: Fix policy name validation rejecting dots
Celinadhh commentedon Jun 25, 2026
The fix has been checked in and will go out in 2.88.0.