question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when deleting Resource Locks via az lock delete galleries/GALLERYNAME/images/IMAGEDEF/verions/n.n.n

See original GitHub issue

This 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:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
johnem-msftcommented, Oct 12, 2022

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.

0reactions
zhoxing-mscommented, Oct 13, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Delete resouce lock using Azure CLI task - Microsoft Q&A
I am using the Azure CLI task in Azure Devops to run a resource lock deletion command against Azure. The following command is...
Read more >
Enforce CanNotDelete Resource Lock using Azure Policy
Resource locks prevent users from deleting or modifying Azure resources. The lock overrides any user's permissions, so even owners cannot modify ...
Read more >
Azure Resource Locks Removal Delay from CLI script
I have a readonly lock on my resource group. At the beginning of my pipeline, I run a Azure CLI script task to...
Read more >
DEMO Azure Locks on Resource Group - YouTube
A cannot- delete lock on a resource group prevents Azure Resource Manager from automatically deleting deployments in the history.
Read more >
Azure - Lock a VM to Prevent Deletion - John Hanley
You have recovered the deleted virtual machine from snapshots. ... Azure supports locking resources at the subscription, resource group, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found