How to Create a Resource Lock in Microsoft Azure
Published: 2023-03-27 09:58:59


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocg62wg56hvo3fvihbm1.png)
Resource Locks are a feature available in Azure to prevent the removal or change of resources. As an administrator, you can lock an Azure subscription, resource group, or resource to protect them from accidental user deletions and modifications. The lock overrides any user permissions.

**Steps to Create a Resource Lock:**

Step 1:

Create a Microsoft Azure account and login(portal.azure.com)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2wrv8f1k7lg0ozr2exy0.png)

Step 2:

Click on the search bar and search for Resource Group

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v42i1u2xq69koc71y7bz.png)

Step 3:

Click on Create

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mrafdspacq1x72xluchq.png)

Step 4:

Subscription: Choose your subscription
Resource Group: Choose a name of your choice
Region: your location or your region
Click on Review and Create

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mvvp0bk239pnekcpoix5.png)

Step 5:

Click on Create

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rcrpaagpgjek3nsnmjq.png)

Step 6:
Your Resource Group is created

Click on it to access it

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ic2b2v7uo4ohuv8lfu02.png)

Step 7:
To add a Lock to your Resource Group

Click on Lock

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ap3kcx6dci3avojnt705.png)

Step 8:

Click on Add
Lock name: Choose any name
Lock type: Choose Read Only or Delete; (CanNotDelete means authorized users can read and modify a resource, but they can't delete it. ReadOnly means authorized users can read a resource, but they can't delete or update it.)
Notes: It helps to pass a message about the lock information
Click on OK

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w7nxwkru6kdzicexbumt.png)

Step 9:
Click Home and search for storage account to create a Storage Account

Click Storage Account

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s7tvrwc5dmehmte416od.png)

Step 10:

Click on Create

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4d6808fm3fvxumbppz8g.png)

Step 11:

Subscription: Choose your subscription
Resource Group: I chose "marchworkload" because it is the resource group I want to lock. I'll advice the same be done always because you're saving your storage account in the resource group.
Storage Account Name: Choose a unique name across all existing accounts in Azure
Region: Choose your region
Click Review

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ibnnoxvqry493h6qjyvi.png)

Step 12:

Click on Create

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ojoijrxmq59fpf6jkjb6.png)

Step 13:
The Storage account has been created

Click on 'Go to resource' to view

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0jf648thsrdd4e488myq.png)

Step 14:
Try to delete and see the error message

Click on Delete in order to test if your resource group lock worked
Copy the resource group name
Paste in the arrow part on the right bottom of your screen
Delete

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y0f4mpgmmufepigknp69.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8pvopmu6qwgd21nwqrg8.png)

Step 15:
The error message displayed is as a result of the locks on the resource group. Locks must be removed before resource can be deleted
This implies that the resource was locked correctly

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ef9fviavpzfw6u9azl6x.png)

Step 16:
The way to successfully remove a lock resource:

Go to Home and click on the resource group
Click on Locks

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2gs34wf9yek2nctbd5dc.png)

Step 17:

Click on Delete
You can also change the lock type to 'Read Only' by clicking on 'edit' close to 'delete'
See the 2nd picture to view what pops up if you want to change the lock type

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ypcxvz2ivw794e066gn6.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fntk2in9bbgl3cycw7id.png)

Step 18:
Go back to the resource group and try to delete the storage account after the removing the lock

Storage account was deleted successfully because of the removal of the locks

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z10vdmujwwvcwshp6e5k.png)