Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: ✔️ Windows VMs ✔️ Linux VMs
Summary
This article explains how to troubleshoot Azure virtual machine (VM) move failures that resource locks cause. It provides steps to identify and remove blocking locks, retry the move, and reapply locks after the move finishes.
Symptoms
A move validation fails and generates lock-related errors. When the error occurs, you receive error messages that indicate that the operation is blocked by a lock.
The following error message is an example of a lock-related error message.
The scope '<resource-id>' cannot perform write operation because the following scope(s) are locked.
Cause
Azure resource locks that are enacted at the subscription, resource group, or resource scope can block move operations.
The most common lock types are the following locks:
CanNotDeleteReadOnly
Important
Not all lock types and scopes block moves equally. In practice, ReadOnly locks at the resource group or subscription scope are the primary cause of ScopeLocked errors during move operations. CanNotDelete locks and resource-level ReadOnly locks typically don't block resource moves. However, you should still remove or temporarily disable all locks on resources in the move request to prevent unexpected behavior during the operation.
Locks on any dependency (VM, network adapter, disks, network security group (NSG), or public IP) can block the entire move transaction.
Resolution
Step 1: Enumerate locks in the source scope
Use Azure PowerShell, Azure CLI, or the Azure portal to enumerate locks in the source scope.
Run the following command.
Get-AzResourceLock -ResourceGroupName "<source-rg>" |
Select-Object LockName, LockLevel, ResourceName, ResourceType
To inspect locks recursively at the subscription scope, run the following command.
Get-AzResourceLock | Select-Object LockName, LockLevel, Scope
Step 2: Remove or temporarily disable blocking locks
If your change process approves, use Azure PowerShell, Azure CLI, or the Azure portal to remove locks that block move execution.
Run the following command.
Remove-AzResourceLock -LockName "<lock-name>" -ResourceGroupName "<source-rg>" -Force
Important
Reapply required governance locks after the move finishes.
Step 3: Retry move validation and move
After lock removal, rerun move validation and complete the move.
Step 4: Reapply locks at destination
After a successful move, reapply CanNotDelete or ReadOnly locks on the destination scope as required by your governance baseline.
References
- Pre-flight checklist for moving Azure VM resources
- Move blocked by failed virtual machine extension
- Lock resources to prevent unexpected changes
Third-party information disclaimer
The third-party products that this article discusses are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, about the performance or reliability of these products.