An Azure service that is used to provision Windows and Linux virtual machines.
As currently suggested by kagiyama and adding more on this:
A ReadOnly lock restricts all authorized users to effectively Reader-level permissions on that resource. It allows read operations, but blocks delete and update (PUT/POST) operations on the management (control) plane. - https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/lock-resources?tabs=json
Important point :
VM start, stop, and restart are POST actions on the control plane, so a ReadOnly lock will block these operations which matches your goal of preventing accidental stop/restart of a critical VM.
However, the same restriction also blocks legitimate operations such as:
- Resizing, reconfiguring, or updating the VM
- Installing/updating VM extensions
- Updating diagnostics settings (these are management-plane writes)
Locks apply only to control-plane operations (https://management.azure.com), not data-plane operations. So, in-guest OS logging, event logs, and applications writing to disk are not affected.
Azure Backup is a control-plane service that must manage restore points and related resources.
A Read-only lock can interfere with backup/extension/diagnostics operations that require write (PUT/POST) calls, and a Cannot Delete lock on the system-created AzureBackupRG_* resource group can cause backups to fail, because the service can't clean up old restore point collections once it hits its limit. - https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/control-plane-and-data-plane
So, a Read-only lock on the VM (or its resource group) is more likely to cause operational/backup side effects than to help.
For most production-critical VMs, the recommended approach is:
- Use a Cannot Delete (Delete) lock on the VM (and optionally its disks). This protects against accidental deletion while still allowing start/stop/restart, resizing, extensions, monitoring, and backups to work normally.
- To specifically restrict stop/restart, use Azure RBAC / a custom role to deny Microsoft.Compute/virtualMachines/powerOff/action, /restart/action, and /deallocate/action for operators. This is the cleaner, targeted way to prevent power actions without the broad side effects of ReadOnly. - https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/lock-resources?tabs=json
- Do not place any lock on the AzureBackupRG_* resource group, as it can break restore point cleanup and cause backup failures