Introduction
When working in Azure Data Factory, it is possible for a user to accidentally delete a resource. To prevent this, we can implement Azure Locks. Azure Locks allow us to create restrictions and prevent accidental resource deletion. This is particularly useful in production environments where developers or administrators may have full access and could unintentionally delete important resources.
Lock Levels
There are two types of lock levels available in Azure Data Factory: CanNotDelete and ReadOnly.
- CanNotDelete: Authorized users are able to read and modify resources, but they cannot delete them. In the portal, this lock is referred to as “Delete”.
- ReadOnly: Authorized users can only read a resource, they cannot delete or modify it. In the portal, this lock is referred to as “Read-only”.
Access Required
In order to create or manage locks, you need to have the following access:
- Must be an owner or User Access Administrator with built-in roles.
- Must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/*.
Create a New Lock
To create a new lock in Azure Data Factory, follow these steps:
- Go to the settings option in Azure Data Factory.
- Look for the “Locks” entry in the menu.
- Click on “Add” to create a new lock.
- Provide a lock name.
- Choose the lock type between “Read-only” and “Delete”.
- Add any optional notes or comments about the lock.
Managing Locks
Once a lock is created, it will be available in the Lock section. From there, you can edit or delete existing locks as needed.
Preventing Resource Deletion
Let’s say you have a demo pipeline called “Pl_Test” in your data factory and you want to prevent it from being accidentally deleted. You can apply a lock to this resource. When you try to delete the pipeline, you will receive an error message indicating that the resource is locked. You will need to remove the lock or undo the delete action in order to proceed.
Conclusion
In this article, we have learned how to use locks in Azure Data Factory to prevent accidental resource deletion. By implementing locks, we can add an extra layer of protection to our resources and minimize the risk of unintentional deletions.