Control: 10.1 Ensure that Resource Locks are set for Mission-Critical Azure Resources
Description
As an administrator, it may be necessary to lock a subscription, resource group, or resource to prevent other users in the organization from accidentally deleting or modifying critical resources. The lock level can be set to to CanNotDelete or ReadOnly to achieve this purpose.
- CanNotDelete means authorized users can still read and modify a resource, but they cannot delete the resource.
 - ReadOnly means authorized users can read a resource, but they cannot delete or update the resource. Applying this lock is similar to restricting all authorized users to the permissions granted by the Reader role.
 
Remediation
From Azure Portal
- Navigate to the specific Azure Resource or Resource Group
 - For each of the mission critical resource, click on 
Locks - Click 
Add - Give the lock a name and a description, then select the type, 
CanNotDeleteorReadOnlyas appropriate 
From Azure CLI
To lock a resource, provide the name of the resource, its resource type, and its resource group name.
az lock create --name <LockName> --lock-type <CanNotDelete/Read-only> --resource-group <resourceGroupName> --resource-name <resourceName> --resourcetype <resourceType>
From Powershel
Get-AzResourceLock -ResourceName <Resource Name> -ResourceType <ResourceType> -ResourceGroupName <Resource Group Name> -Locktype <CanNotDelete/Readonly>
Default Value
By default, no locks are set.
Usage
Run the control in your terminal:
powerpipe control run azure_compliance.control.cis_v150_10_1Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run azure_compliance.control.cis_v150_10_1 --shareSQL
This control uses a named query:
select  id as resource,  'info' as status,  'Manual verification required.' as reason,  display_name as subscriptionfrom  azure_subscription;