Share via

I can't delete a VM that is part of the subscription that I am an owner of.

pkrane 0 Reputation points
2026-05-28T06:50:07.2033333+00:00

Attempting to delete the VM from the Azure Portal receives the follow error:

  • Resource/subscriptions/<my subscription>/resourcegroups/<my resource group>/providers/Microsoft.Compute/virtualMachines/my virtual machine>
  • Operation name: Delete Virtual Machine
  • Time stamp: Wed May 27 2026 16:58:55 GMT-0400 (Eastern Daylight Time)
  • Event initiated by: <my admin id>
  • Error code: ResourceOperationFailure
  • Message: The resource operation completed with terminal provisioning state 'Failed'.

I have manually deleted the attached disk successfully. It doesn't show up anymore.

I have tried a dozen times to delete the network interface. Azure still shows the network interface. Each attempt to detach the interface - I am met with "No network interfaces available to detach". That network interface is not attached to any other resource.

Every attempt to redeploy the VM fails.

I check for resource locks. The response: "This resource has no locks."

I can attempt to update the VM - "Operation 'Update VM' is not allowed on VM '<my VM>' since the VM is marked for deletion. You can only retry the Delete operation (or wait for an ongoing one to complete)."

When I retry the deletion, without trying to delete any attached resources. The activity log shows that the Deletion has been started but ultimately fails with the first message of this issue - "The resource operation completed with terminal provisioning state 'Failed'."

CoPilot does not seem to help. All suggested CLI commands either fail or look like they are successful but, in the end, I end up with all of the same errors above.

Is there something obvious that I doing wrong?

Azure Virtual Machines
Azure Virtual Machines

An Azure service that is used to provision Windows and Linux virtual machines.

0 comments No comments

3 answers

Sort by: Most helpful
  1. pkrane 0 Reputation points
    2026-05-28T07:39:40.5733333+00:00

    Accepted. There was Page Blob attached to the resource. I deleted it and am trying the delete again.

    Was this answer helpful?


  2. Himanshu Shekhar 6,700 Reputation points Microsoft External Staff Moderator
    2026-05-28T07:04:19.8733333+00:00

    Hey there! It looks like your VM is stuck in a “Failed” delete state because Azure still thinks there’s a network interface (NIC) attached—even though you don’t see one in the portal. When a resource’s provisioningState is stuck, the portal UI sometimes hides it, but you can still force-delete via CLI/PowerShell or the REST API.

    Here’s what you can try:

    1. Confirm the NIC really exists (and see its provisioning state)
      • Azure CLI
        
             az network nic list \
        
               --resource-group <your-RG> \
        
               --query "[].{Name:name, Id:id, State:provisioningState}" \
        
               -o table
        
        
      • PowerShell
        
             Get-AzNetworkInterface -ResourceGroupName <your-RG> |
        
               Select-Object Name, Id, ProvisioningState
        
        
    2. Force-delete the orphaned NIC
      • Azure CLI
        
             az network nic delete --ids <NIC-Id> --no-wait
        
        
      • PowerShell
        
             Get-AzNetworkInterface -ResourceGroupName <your-RG> -Name <nicName> |
        
               Remove-AzNetworkInterface -Force
        
        
    3. Delete the VM resource itself
      • Azure CLI
        
             az vm delete \
        
               --resource-group <your-RG> \
        
               --name <yourVM> \
        
               --yes \
        
               --no-wait
        
        
      • Or via the generic resource delete (this ignores dependencies)
        
             az resource delete \
        
               --ids /subscriptions/<subId>/resourceGroups/<your-RG>/providers/Microsoft.Compute/virtualMachines/<yourVM>
        
        
    4. (Optional) If your VM is the only resource in that resource group, you can drop the entire group in one go:
      
         az group delete -n <your-RG> --yes --no-wait
      
      
    5. Use Resource Explorer / REST API if CLI/PowerShell still fails
      • Head to https://resources.azure.com
      • Navigate to your subscription → resourceGroups → … → virtualMachines → <yourVM>
      • Click “DELETE” in the JSON pane to force the delete

    If after all this the VM/NIC are still stuck, you’ll need to open an Azure Support ticket so the backend engineers can clear the stale resource state.

    Hope that helps! Let me know how it goes.

    References

    Was this answer helpful?


  3. AI answer

    2026-05-28T06:50:33.3033333+00:00

    Use a dependency‑first cleanup approach and then retry the VM delete, focusing on the NIC and any remaining dependent resources.

    1. Verify and remove all VM dependencies
      • In the Azure portal, open the VM blade and note:
        • Resource group
        • Network interface(s)
        • OS/data disks
        • Any boot diagnostics storage account/container
      • Since the OS disk is already deleted, manually remove remaining dependencies in the same resource group:
        • Network interface
        • Any remaining data disks
        • Boot diagnostics storage container (if present)
      If the resource group itself can be deleted, that is the simplest way to remove a VM and all dependencies together. If the resource group cannot be deleted (because it contains other resources that must be kept), continue with the manual steps.
    2. Force‑remove the NIC via PowerShell (Azure Stack Hub pattern)
      • Connect a PowerShell session to the environment and retrieve the VM object, then pipe it to remove the NIC and VM, following the Azure Stack Hub pattern:
         $machineName = 'VM_TO_DELETE'
         $resGroupName = 'RESOURCE_GROUP'
         $machine = Get-AzVM -Name $machineName -ResourceGroupName $resGroupName
         
         # Remove the virtual network interface
         $machine | Remove-AzNetworkInterface -Force
         
         # Finally, delete the VM
         $machine | Remove-AzVM -Force
      
      For environments using AzureRM modules instead of Az modules, the equivalent cmdlet is:
         $machine = Get-AzureRmVM -Name $machineName -ResourceGroupName $resGroupName
         $machine | Remove-AzureRmNetworkInterface -Force
         $machine | Remove-AzureRmVM -Force
      
      This pattern removes the NIC directly from the VM object, which can clear stale associations that block deletion in the portal.
    3. Confirm storage leases are not blocking deletion
      • If the VM used unmanaged disks (page blobs), verify that no leased page blobs remain attached to a VM:
        1. In the Azure portal, go to the storage account → Blob serviceContainers.
        2. Open each container and look for blobs with Blob Type = Page blob and Lease State = Leased.
        3. For each such blob, open Edit Metadata and check MicrosoftAzureCompute_VMName and MicrosoftAzureCompute_DiskType to identify the VM and whether it is an OSDisk or DataDisk.
        4. If the disk type is OSDisk, ensure the VM is deleted (Step 2 above). If it is DataDisk, detach it from the VM and then delete the disk.
        5. If MicrosoftAzureCompute_VMName and MicrosoftAzureCompute_DiskType are missing, the blob is explicitly leased but not attached to a VM. Break the lease by selecting Break lease, then delete the blob.
      • After deleting the VM, verify that any VHD blobs used by the VM show Lease Status = Available in the blob properties.
    4. If the VM still cannot be deleted
      • Ensure no virtual network or subnet dependencies are blocking cleanup (for example, NICs, private endpoints, or service association links on the subnet). Use diagnostic commands (Azure CLI) to list subnet dependencies and remove any remaining IP configurations or links before retrying deletion.
      • Once all dependent resources (NICs, disks, diagnostic containers, subnet associations) are removed, retry the VM delete operation from the portal or via PowerShell.

    This sequence aligns with the documented approach for removing VMs that are stuck because of dependent resources, especially unmanaged disks and NICs.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.