Error when deleting Resource Locks via az lock delete galleries/GALLERYNAME/images/IMAGEDEF/verions/n.n.n
See original GitHub issueThis is autogenerated. Please review and update as needed.
When attempting to delete a resource lock created successfully from the Portal for an image definition version, an error is encountered: az resource lock delete --resource-name /subscriptions/<SUB-ID>/resourceGroups/RESOURCE-GROUP/providers/Microsoft.Compute/galleries/GALLERY-NAME/images/IMAGEDEF-NAME/versions/n.n.n.n/providers/Microsoft.Authorization/locks/LOCKNAME --resource-group RESOURCE-GROUP --resource-type Microsoft.Compute/galleries
Error: The command failed with an unexpected error. Here is the traceback: No value for given attribute 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 663, in execute raise ex File “/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py”, line 726, 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 697, in _run_job result = cmd_copy(params) File “/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py”, line 333, in call return self.handler(*args, **kwargs) File “/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py”, line 121, in handler return op(**command_args) File “/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/resource/custom.py”, line 3173, in delete_lock return lock_client.management_locks.delete_at_resource_level( File “/usr/lib64/az/lib/python3.9/site-packages/azure/core/tracing/decorator.py”, line 73, in wrapper_use_tracer return func(*args, **kwargs) File “/usr/lib64/az/lib/python3.9/site-packages/azure/mgmt/resource/locks/v2016_09_01/operations/_operations.py”, line 1284, in delete_at_resource_level request = build_management_locks_delete_at_resource_level_request( File “/usr/lib64/az/lib/python3.9/site-packages/azure/mgmt/resource/locks/v2016_09_01/operations/_operations.py”, line 342, in build_management_locks_delete_at_resource_level_request “lockName”: _SERIALIZER.url(“lock_name”, lock_name, ‘str’), File “/usr/lib64/az/lib/python3.9/site-packages/msrest/serialization.py”, line 652, in url output = self.serialize_data(data, data_type, **kwargs) File “/usr/lib64/az/lib/python3.9/site-packages/msrest/serialization.py”, line 760, in serialize_data raise ValueError(“No value for given attribute”) ValueError: No value for given attribute
The following attempt to create a lock for an Image Gallery Version also fails: az resource lock create --lock-type ReadOnly -n <LOCKNAME> -g <RESOURCEGROUP-NAME> --resource /subscriptions/<SUB-ID>/resourceGroups/<RESOURCEGROUP-NAME>/providers/Microsoft.Compute/galleries/<GALERY-NAME>/images/<IMAGE-NAME>/versions/n.n.n --resource-type Microsoft.Compute/galleries/images/versions The command failed with an unexpected error. Here is the traceback: No value for given attribute 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 663, in execute raise ex File “/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py”, line 726, 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 697, in _run_job result = cmd_copy(params) File “/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py”, line 333, in call return self.handler(*args, **kwargs) File “/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py”, line 121, in handler return op(**command_args) File “/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/resource/custom.py”, line 3213, in create_lock return lock_client.management_locks.create_or_update_at_resource_level( File “/usr/lib64/az/lib/python3.9/site-packages/azure/core/tracing/decorator.py”, line 73, in wrapper_use_tracer return func(*args, **kwargs) File “/usr/lib64/az/lib/python3.9/site-packages/azure/mgmt/resource/locks/v2016_09_01/operations/_operations.py”, line 1198, in create_or_update_at_resource_level request = build_management_locks_create_or_update_at_resource_level_request( File “/usr/lib64/az/lib/python3.9/site-packages/azure/mgmt/resource/locks/v2016_09_01/operations/_operations.py”, line 291, in build_management_locks_create_or_update_at_resource_level_request “resourceProviderNamespace”: _SERIALIZER.url(“resource_provider_namespace”, resource_provider_namespace, ‘str’), File “/usr/lib64/az/lib/python3.9/site-packages/msrest/serialization.py”, line 652, in url output = self.serialize_data(data, data_type, **kwargs) File “/usr/lib64/az/lib/python3.9/site-packages/msrest/serialization.py”, line 760, in serialize_data raise ValueError(“No value for given attribute”) ValueError: No value for given attribute
ASK: -How do we create and delete locks for Azure Compute Gallery Definitions in az cli using az lock create -or az resource lock create?
Command Name
az lock delete
Errors:
Unexpected --namespace for lock LOCKNAME expected Microsoft.Compute
To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
- Put any pre-requisite steps here…
az lock delete --name {} --resource-group {} --resource {} --resource-type {}
Expected Behavior
Environment Summary
Linux-5.4.0-1091-azure-x86_64-with-glibc2.35 (Cloud Shell), CBL-Mariner/Linux
Python 3.9.13
Installer: RPM
azure-cli 2.40.0
Extensions:
vm-repair 0.4.1
image-copy-extension 0.2.9
serial-console 0.1.2
ai-examples 0.2.5
ml 2.7.1
ssh 1.1.2
Dependencies:
msal 1.18.0b1
azure-mgmt-resource 21.1.0b1
Additional Context
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Thanks so much Xing Zhou!!
I confirmed that I was able to list a lock created via gui via: az lock list and then use that info to delete the log - eg:
az resource lock delete -n LOCKSIGVERSIONLOCKNAME --resource “1.1.1” -g UKSOUTH --resource-type Microsoft.Compute/versions --parent galleries/AZCOMPUTEGALLERYNAME/images/IMAGEDEFNAME
In the same fashion I was also able to recreate the lock as follows:
Create Azure Compute Gallery Version Lock via Az CLI:
az resource lock create -n LOCKSIGVERSIONLOCKNAME --resource “1.1.1” -g UKSOUTH --resource-type Microsoft.Compute/versions --parent galleries/AZCOMPUTEGALLERYNAME/images/IMAGEDEFNAME --lock-type CanNoteDelete
az lock list confirms successful creation as well.
If there are no other questions, I will close the issue first. If you have other questions in the future, please feel free to contact us