HOW TO ADD LOCKS TO RESOURCE GROUP
Tags: azure, webdev, javascript, beginners
Published: 2023-03-20 00:41:49

Resource locks protect your Azure resources from accidental deletion or modification,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. You can set locks that prevent either deletions or modifications. In the portal, these locks are called Delete and Read-only


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

**HOW TO LOCK A RESOURCE GROUP**

To do this
-we will create a resource group
-lock the resource group

**HOW TO CREATE A RESOURCE GROUP**

**Go to azure account**

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

**search resource group**


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

**click on create**


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

**give the resource group a name**
**review and create**

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

**create**

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

**resource group is ready**


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


Now the resource group is ready, lets proceed to lock it.

**-open the resource group and click on lock**


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


**click "add"**

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

**give the lock a name**

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

**LOCK TYPES**
READ ONLY-means authorized users can read and modify a resource, but they can't delete it.

DELETE- means authorized users can read a resource, but they can't delete or update it

**FOR THIS TUTORIAL WE WILL USE THE DELETE LOCK TYPE**

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

**ADD A NOTE**

CLICK "ok"


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



for this tutorial we will create a storage account and add to the resource group created, then we try to delete


if you dont know how to create a storage account 

[CLICK HERE](https://dev.to/dunk_wee/how-to-create-a-storage-account-on-azure-5d4f)


we created a storage account "testlockdelete2023"
Now lets try to delete


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

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

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

**AS YOU CAN SEE THE LOCK PREVENTS THE CODE FROM DELETION**