How to Resolve the “ScopeLocked” Error in Azure DevOps ARM Template Deployment

Luca Berton
5 min readJust now

When using Azure DevOps and the Azure CLI to manage resources, you might encounter the following error while attempting to delete a resource group or storage account:

ERROR: (ScopeLocked) The scope '/subscriptions/REDUCTED/resourcegroups/lab-rg' cannot perform delete operation because following scope(s) are locked: '/subscriptions/REDUCTED/resourcegroups/lab-rg/providers/microsoft.storage/storageaccounts/alab740'. Please remove the lock and try again.

This error occurs when an Azure resource, such as a resource group or storage account, is locked. Resource locks are placed on Azure resources to prevent accidental deletion or modification. To perform the delete operation, you must first remove the lock.

What is a Resource Lock in Azure?

Azure provides resource locks to help prevent unintended changes to critical resources. There are two types of locks:

  • Read-Only Lock: Allows reading the resource but prevents any changes.
  • Delete Lock: Prevents deletion of the resource.

In this scenario, the resource /subscriptions/.../resourcegroups/lab-rg/providers/microsoft.storage/storageaccounts/alab740 is locked, which is why the delete operation is…

--

--

Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday