Skip to content

--namespace parameter validation in 'az lock delete' is inconsistent wrt case sensitivity #31188

Open
@Salazander

Description

@Salazander

Describe the bug

'az lock delete' is exhibiting inconsistent behavior regarding the case sensitivity of the namespace, specifically between 'Microsoft.Storage' and 'microsoft.storage'.

Related command

az lock delete --name AzureBackupProtectionLock --resource-group resourcegroupname --resource-type storageAccounts --resource-name storageaccountname --namespace "microsoft.storage"

Errors

File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/resource/custom.py", line 4011, in _validate_lock_params_match_lock
raise CLIError(
knack.util.CLIError: Unexpected --namespace for lock AzureBackupProtectionLock, expected microsoft.storage

cli.azure.cli.core.azclierror: Unexpected --namespace for lock AzureBackupProtectionLock, expected microsoft.storage
az_command_data_logger: Unexpected --namespace for lock AzureBackupProtectionLock, expected microsoft.storage

Issue script & Debug output

az lock delete --debug --name "AzureBackupProtectionLock" --namespace "Microsoft.Storage" --resource-group "XYZXYZXYZ-tenantrg" --resource-name "storageaccountxxxx" --resource-type "storageAccounts"
cli.knack.cli: Command arguments: ['lock', 'delete', '--debug', '--name', 'AzureBackupProtectionLock', '--namespace', 'Microsoft.Storage', '--resource-group', 'XYZXYZXYZ-tenantrg', '--resource-name', 'storageaccountxxxx', '--resource-type', 'storageAccounts']
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 0x7f37fa556280>, <function OutputProducer.on_global_arguments at 0x7f37fa410d30>, <function CLIQuery.on_global_arguments at 0x7f37fa3b0310>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'lock': ['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: resource 0.189 52 232
cli.azure.cli.core: Total (1) 0.189 52 232
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.085 1 1 /usr/lib/python3.9/site-packages/azure-cli-extensions/ai-examples
cli.azure.cli.core: Total (1) 0.085 1 1
cli.azure.cli.core: Loaded 53 groups, 233 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : lock delete
cli.azure.cli.core: Command table: lock delete
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7f37f9846b80>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/gaaa/.azure/commands/2025-04-01.06-29-24.lock_delete.3502.log'.
az_command_data_logger: command args: lock delete --debug --name {} --namespace {} --resource-group {} --resource-name {} --resource-type {}
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x7f37f97e88b0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x7f37f978b820>, <function register_cache_arguments..add_cache_arguments at 0x7f37f97a5700>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x7f37f97a5790>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7f37fa410dc0>, <function CLIQuery.handle_query_parameter at 0x7f37fa3b03a0>, <function register_ids_argument..parse_ids_arguments at 0x7f37f97a5670>]
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ManagementLockClient
cli.azure.cli.core.auth.persistence: build_persistence: location='/home/gaaa/.azure/service_principal_entries.json', encrypt=False
cli.azure.cli.core.auth.persistence: build_persistence: location='/home/gaaa/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /home/gaaa/.azure/msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: Initializing with Entra authority: https://login.microsoftonline.com/66666666-92d2-40b2-9ffd-c9c94280c757
msal.authority: openid_config("https://login.microsoftonline.com/66666666-92d2-40b2-9ffd-c9c94280c757/v2.0/.well-known/openid-configuration") = {'token_endpoint': 'https://login.microsoftonline.com/66666666-92d2-40b2-9ffd-c9c94280c757/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/66666666-92d2-40b2-9ffd-c9c94280c757/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/66666666-92d2-40b2-9ffd-c9c94280c757/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/66666666-92d2-40b2-9ffd-c9c94280c757/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/66666666-92d2-40b2-9ffd-c9c94280c757/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/66666666-92d2-40b2-9ffd-c9c94280c757/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/66666666-92d2-40b2-9ffd-c9c94280c757/kerberos', 'tenant_region_scope': 'NA', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
msal.application: Broker enabled? None
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_credentials: ServicePrincipalCredential.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 5372e1e4-09b0-4c37-842a-583bd632ec9d
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/0ef62f60-7777-7777-7777-6022a9e2c9a6/providers/Microsoft.Authorization/locks?api-version=2016-09-01'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': 'a713242c-0ec2-11f0-a8e9-00155d6c705e'
cli.azure.cli.core.sdk.policies: 'CommandName': 'lock delete'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--debug --name --namespace --resource-group --resource-name --resource-type'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.70.0 (RPM) azsdk-python-core/1.31.0 Python/3.9.19 (Linux-6.1.91.1-microsoft-standard-x86_64-with-glibc2.35) cloud-shell/1.0'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/0ef62f60-7777-7777-7777-6022a9e2c9a6/providers/Microsoft.Authorization/locks?api-version=2016-09-01 HTTP/1.1" 200 1004
cli.azure.cli.core.sdk.policies: Response status: 200
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Content-Length': '1004'
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies: 'Expires': '-1'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': 'ffa1b9e3-acc6-402f-8a46-d2ae96144c54'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': 'ffa1b9e3-acc6-402f-8a46-d2ae96144c54'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'WESTEUROPE:20250401T062925Z:ffa1b9e3-acc6-402f-8a46-d2ae96144c54'
cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: 4E475AD859C3473C9230D288BB5D2933 Ref B: AMS231020614017 Ref C: 2025-04-01T06:29:24Z'
cli.azure.cli.core.sdk.policies: 'Date': 'Tue, 01 Apr 2025 06:29:24 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"value":[{"properties":{"level":"CanNotDelete","notes":"Azure Backup protection lock to prevent accident deletion of storage account."},"id":"/subscriptions/0ef62f60-7777-7777-7777-6022a9e2c9a6/resourcegroups/XYZXYZXYZ-tenantrg/providers/Microsoft.Storage/storageAccounts/storageaccountxxxx/providers/Microsoft.Authorization/locks/AzureBackupLock-DoNotDelete","type":"Microsoft.Authorization/locks","name":"AzureBackupLock-DoNotDelete"},{"properties":{"level":"CanNotDelete","notes":"Auto-created by Azure Backup for storage accounts registered with a Recovery Services Vault. This lock is intended to guard against deletion of backups due to accidental deletion of the storage account."},"id":"/subscriptions/0ef62f60-7777-7777-7777-6022a9e2c9a6/resourcegroups/XYZXYZXYZ-tenantrg/providers/microsoft.storage/storageAccounts/storageaccountxxxx/providers/Microsoft.Authorization/locks/AzureBackupProtectionLock","type":"Microsoft.Authorization/locks","name":"AzureBackupProtectionLock"}]}
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 666, in execute
raise ex
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 734, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job
result = cmd_copy(params)
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 336, in call
return self.handler(*args, **kwargs)
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/resource/custom.py", line 4150, in delete_lock
_validate_lock_params_match_lock(lock_client, lock_name, resource_group,
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/resource/custom.py", line 4011, in _validate_lock_params_match_lock
raise CLIError(
knack.util.CLIError: Unexpected --namespace for lock AzureBackupProtectionLock, expected microsoft.storage

cli.azure.cli.core.azclierror: Unexpected --namespace for lock AzureBackupProtectionLock, expected microsoft.storage
az_command_data_logger: Unexpected --namespace for lock AzureBackupProtectionLock, expected microsoft.storage
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f37f9846dc0>]
az_command_data_logger: exit code: 1
cli.main: Command ran in 1.589 seconds (init: 0.176, invoke: 1.413)
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 4192 in cache file under /home/gaaa/.azure/telemetry/20250401062925263
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/gaaa/.azure /home/gaaa/.azure/telemetry/20250401062925263"
telemetry.process: Return from creating process 3512
telemetry.main: Finish creating telemetry upload process.

Expected behavior

"microsoft.storage" and "Microsoft.Storage" should both be treated equivalently regardless of the casing convention

Environment Summary

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

Additional context

No response

Metadata

Metadata

Assignees

Labels

ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupAuto-AssignAuto assign by botAuto-ResolveAuto resolve by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamPossible-SolutionSimilar-IssuequestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions