Reputation: 1575
I have created a lock of type CanNotDelete on a storage account in Azure. The lock works; I cannot delete the storage account as long as the lock exists. I can get the name and ID of the lock by doing this:
az lock list --resource-group "my-resource-group-name
Now I try to delete the lock from the command line like this:
az lock delete --resource-group "my-resource-group-name --name "name-of-my-lock"
This produces no output (no error message nor confirmation) and does nothing. The lock is still there.
If I add the --debug
and --verbose
flags to the delete command, I can see that the delete request returns HTTP 204. Still does nothing, though.
My user account has Owner rights. I can delete the lock via the Azure browser-based GUI (logged in as the same user). That works fine. But the command line does not work.
Upvotes: 2
Views: 4129
Reputation: 136366
You can try to delete the lock by specifying the lock id. For example, when I do
az lock list --resource-group "my-resource-group-name"
I get the following result:
[
{
"id": "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Storage/storageAccounts/<storage-account-name>/providers/Microsoft.Authorization/locks/<lock-name>",
"level": "CanNotDelete",
"name": "<lock-name>",
"notes": "",
"owners": null,
"resourceGroup": "<resource-group-name>",
"type": "Microsoft.Authorization/locks"
}
]
I can then delete this lock using the following command:
az lock delete --ids "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Storage/storageAccounts/<storage-account-name>/providers/Microsoft.Authorization/locks/<lock-name>"
Upvotes: 1