Unknown error while deleting VMSS

Sergey Borovoy 521 Reputation points
2024-09-18T12:25:11.15+00:00

I need to delete a VMSS but I can't because every time I get this error: "An unexpected error occured while processing the network profile of the VM. Please retry later."

I suspect that the problem is in the NIC. The Network Settings blade says that my Network interface is "qa-be-asNic" but such NIC does not exist. I tried creating and attaching a new NIC but got this error:

"Failed to attach network interface 'nic-temporary-to-be-deleted' to virtual machine 'qa-be-as'. Error: Operation 'Update Virtual Machine Scale Set' is not allowed on Virtual Machine Scale Set 'qa-be-as' since it is marked for deletion. For more information on your operations, please refer to https://aka.ms/activitylog."

So, in a nutshell: I cannot delete my VMSS because it's screwed up, but I also cannot un-screw it because it's marked for deletion.

Any ideas? Thanks.

Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
408 questions
{count} votes

Accepted answer
  1. anashetty 740 Reputation points Microsoft Vendor
    2024-09-19T11:48:19.9233333+00:00

    Hi Sergey Borovoy,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    We understand from your query that you are experiencing an issue while trying to delete VMSS. Here are few suggestions to help you.

    You may need to stop any pending or ongoing operations through the Activity Log: Navigate to the Azure portal and open the VMSS resource. Go to the "Activity log" tab, and filter by "Operation name" to find any operations related to the VMSS. Review the status of each operation, and check if any operations are in pending or running state, you can attempt to cancel them. After that try cancelling VMSS again.

    You can force delete VMSS through Azure CLI or PowerShell

    PowerShell**:** You can use the Remove-AzVmss cmdlet to force the deletion of the VMSS

    Remove-AzVmss -ResourceGroupName <resource-group-name> -VMScaleSetName <vmss-name> -Force
    

    For more information, please refer to https://learn.microsoft.com/en-us/powershell/module/az.compute/remove-azvmss?view=azps-12.3.0&viewFallbackFrom=azps-5.9.0

    Azure CLI**:** You can use the az vmss delete command to force the deletion of the VMSS

    az vmss delete --resource-group <resource-group-name> --name <vmss-name> --force
    

    For more information, please refer to https://learn.microsoft.com/en-us/cli/azure/vmss?view=azure-cli-latest#az-vmss-delete

    Detach NIC from the VMSS Instance: If the NIC issue is blocking the deletion, you can do this through the Azure CLI or PowerShell

    To list all NIC in Resource group via Azure CLI:

     az network nic list --resource-group <resource-group-name>
    

    For more information, please refer to https://learn.microsoft.com/en-us/cli/azure/network/nic?view=azure-cli-latest#az-network-nic-list

    To list all NIC in Resource group via PowerShell:

    Get-AzNetworkInterface -ResourceGroupName <resource-group-name>
    

    For more information, please refer to https://learn.microsoft.com/en-us/powershell/module/az.network/get-aznetworkinterface?view=azps-12.3.0&viewFallbackFrom=azps-5.9.0

    Try to detach NIC manually through Azure CLI or PowerShell:

    az vmss update --resource-group <resource-group-name> --name <vmss-name> --remove virtualMachines 0 networkProfile.networkInterfaces
    
    $vmss = Get-AzVmss -ResourceGroupName <resource-group-name> -VMScaleSetName <vmss-name>
    $vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaces.Remove($vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaces[0])
    Update-AzVmss -ResourceGroupName <resource-group-name> -VMScaleSetName <vmss-name> -VirtualMachineScaleSet $vmss
    

    If this doesn't work, please provide more details regarding this issue. If you have any further queries, please do let us know.

    If the answer is helpful, please click "Accept Answer" and "Upvote it."User's image


0 additional answers

Sort by: Most helpful

Your answer

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