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."