DEV Community

Umar Abdulqadri
Umar Abdulqadri

Posted on

Manage resource locks

Task 1: Adding a Lock to the resource group and test deletion

  • Sign in to the Azure portal.

  • In the Azure portal, navigate to the resource group umarproject.

  • You can apply a lock to a subscription, resource group, or individual resource to prevent accidental deletion or modification of critical resources.

  • In the Settings section, click Locks, and then click + Add fill the details and click ok.

Image description

Image description

  • Click Overview and click Delete resource group. Type the name of the resource group and click OK. You receive an error message stating the resource group is locked and can’t be deleted.

Image description

Task 2: Test deleting a member of the resource group

  • Search for and select Storage accounts, and then + Create

  • On the Storage Accounts page +Create, pick the name of the resource group that was lock earlier and then fill in the storage name. Leave the defaults for everything else. as shown in the below image

Image description

  • Click Review + Create to review your storage account settings and allow Azure to validate the configuration.

  • Once validated, click Create. Wait for the notification that the account was successfully created.

  • Wait for the notification that the storage account was successfully created.

  • Access your new storage account and from the Overview pane, click Delete. You receive an error message stating the resource or its parent has a delete lock.

Image description
Note: Although we did not create a lock specifically for the storage account, we did create a lock at the resource group level, which contains the storage account. As such, this parent level lock prevents us from deleting the resource and the storage account inherits the lock from the parent.

Task 3: Remove the resource lock

  • Return to the umarproject resource group blade and, in the Settings section, click Locks.

Click Delete link to the far right of the umarproject entry, to the right of Edit.

Image description

  • Return to the storage account blade and confirm you can now delete the resource.

*Congratulations! You created a resource group, added a lock to resource group and tested deletion, tested deleting a resource in the resource group, and removed the resource lock.
*

**Note: **To avoid additional costs, you can optionally remove this resource group. Search for resource groups, click your resource group, and then click Delete resource group. Verify the name of the resource group and then click Delete. Monitor the Notifications to see how the delete is proceeding.

Top comments (0)