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.

[ResourceManager] Unable to delete locks

See original GitHub issue

az lock delete --name $LOCKNAME does not return any value and seems to have no impact

My specific use case: I am unable to delete or update a lock associate with a storage account which itself was associated with a function app. I want to delete the storage account after having deleted a function app via CLI.

There appears to be no workaround since the Portal no longer gives me access to the function settings (and locks).

Steps to reproduce:

az appservice web delete --name shortlinkservice --resource-group shortlinkservice-group
az storage account delete --name function92f1a43683ee --resource-group shortlinkservice-group
Are you sure you want to perform this operation? (y/n): y
The scope '/subscriptions/203c6e23-7c41-47de-8f9f-2ad1807ae229/resourceGroups/shortlinkservice-group/providers/Microsoft.Storage/storageAccounts/function92f1a43683ee' cannot perform delete operation because following scope(s) are locked: '/subscriptions/203c6e23-7c41-47de-8f9f-2ad1807ae229/resourcegroups/shortlinkservice-group/providers/Microsoft.Storage/storageAccounts/function92f1a43683ee'. Please remove the lock and try again.
az lock list
[
  {
    "id": "/subscriptions/203c6e23-7c41-47de-8f9f-2ad1807ae229/resourcegroups/shortlinkservice-group/providers/Microsoft.Storage/storageAccounts/function92f1a43683ee/providers/Microsoft.Authorization/locks/function92f1a43683ee",
    "level": "CanNotDelete",
    "name": "function92f1a43683ee",
    "notes": "One or more function apps were linked to this storage account. You can see all the function apps linked to the account under 'files' or 'shares'.",
    "type": "Microsoft.Authorization/locks"
  }
]
az lock delete --name function92f1a43683ee

(no return value or error)

az lock list
[
  {
    "id": "/subscriptions/203c6e23-7c41-47de-8f9f-2ad1807ae229/resourcegroups/shortlinkservice-group/providers/Microsoft.Storage/storageAccounts/function92f1a43683ee/providers/Microsoft.Authorization/locks/function92f1a43683ee",
    "level": "CanNotDelete",
    "name": "function92f1a43683ee",
    "notes": "One or more function apps were linked to this storage account. You can see all the function apps linked to the account under 'files' or 'shares'.",
    "type": "Microsoft.Authorization/locks"
  }
]
az lock update --name function92f1a436833ee
The lock 'function92f1a436833ee' could not be found.

Stuck.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
johnpapacommented, May 3, 2017

I had similar problems. However I had to include the resource type, name, resource group and resource name flags to remove the lock.

az lock delete --name functione79b3418af65 --resource-group papaResourceGroup --resource-type=Microsoft.Storage/storageAccounts --resource-name functione79b3418af65
1reaction
tjprescottcommented, Mar 31, 2017

@berndverst, since the lock is on the storage account, even though you can’t access the deleted function app, you should be able to access and delete the lock on the storage account in the portal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Protect your Azure resources with a lock - Microsoft Learn
A cannot-delete lock on a resource group prevents Azure Resource Manager from automatically deleting deployments in the history.
Read more >
Protecting Azure Resources with Resource Manager Locks
Resource Manager Locks provide a way for administrators to lock down Azure resources to prevent deletion or changing of a resource.
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 >
Cannot perform delete operation because the scope is locked ...
How to remove Azure Resource lock so you can delete the Azure resource? ... Open the resource you want to delete and select...
Read more >
Learn using Resource Locks - Testprep Training Tutorials
A cannot-delete lock on a resource group prevents Azure Resource Manager from automatically deleting deployments in the history. A cannot-delete lock on the ......
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