At times, Azure resource groups could be accidentally deleted by some users inadvertently, in order to get around this problem Resource groups locks can be set up, they could be set up different parent levels – At subscription levels, Resource Groups levels or Resource level’s etc. Locks can be created either using Azure portal or Power shell.
- Using portal, you can use the following approach. For instance, if you have created a resource group you can navigate to the locks section in the left menu and click on Add button to create a lock. Here I created a resource group named “testmappingdataflows”, and navigated to Locks in settings to create a lock to disable deletion as outlined below.
- Using Powershell, you can use create and apply locks using the following command:
New-AzureRmResourceLock -LockLevel CanNotDelete -LockName criticalStorageLock -ResourceName criticalstorageaccount1 -ResourceType Microsoft.Storage/storageAccounts -ResourceGroupName CriticalStorageRG
Locks is a very useful feature to restrict accidental deletion.