Level 1
0 / 100 XP

Resource Locks

In this lesson, we'll delve into the purpose of resource locks in Azure and how they help prevent accidental changes or deletions of critical resources. Even with Azure role-based access control (Azure RBAC) in place, there's always a risk that users with the necessary permissions might unintentionally delete or modify important resources. Resource locks provide an additional layer of protection by restricting such actions.

What are Resource Locks?

Resource locks are settings applied to Azure resources to prevent them from being deleted or modified. They can be applied at different levels, including individual resources, resource groups, or even entire subscriptions. These locks are inherited, so if you apply a lock to a resource group, all resources within that group will also inherit the lock.

Types of Resource Locks

There are two types of resource locks in Azure:

  1. Delete Lock :
    • Function : Prevents authorized users from deleting the resource.
    • Permissions : Users can still read and modify the resource, but deletion is restricted.
  2. ReadOnly Lock :
    • Function : Prevents authorized users from modifying or deleting the resource.
    • Permissions : Users can only read the resource. This lock essentially restricts all users to the permissions granted by the Reader role.

Managing Resource Locks

Resource locks can be managed through various methods:

  • Azure Portal : Navigate to the Settings section of any resource’s pane in the Azure portal to view, add, or delete locks.
  • PowerShell : Use Azure PowerShell commands to manage resource locks.
  • Azure CLI : Employ Azure CLI commands for lock management.
  • Azure Resource Manager Templates : Define and apply locks using Azure Resource Manager templates.

Example Scenario

Consider a scenario where you have a critical database that should not be deleted under any circumstances. Applying a **Delet…