Trying to remove resources, linked to non existent VMs

James Hart 1 Reputation point
2020-12-14T15:26:48.067+00:00

Hello,

I have been trying to remove some resources from my resource group in my Azure Portal but they appear to be attached to a non existent VM. i get the errors relating to dissociating the network interfaces and virtual network from the resource group.

Below is the error i get (with info removed that may be sensitive to my tenant)

aadds-redacted-nic: Network Interface /subscriptions/redacted/resourceGroups/AzureAD-AADS/providers/Microsoft.Network/networkInterfaces/aadds-redacted-nic is used by existing resource /subscriptions/redacted/resourceGroups/Cust-redacted/providers/Microsoft.Compute/virtualMachines/redacted.32dd2a58. In order to delete the network interface, it must be dissociated from the resource. To learn more, see aka.ms/deletenic. (Code: NicInUse)

The issue is that the virtual machine does not exist so i cannot remove the nic, nsg or vnet.

Thanks in advance for your help
James

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,450 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. suvasara-MSFT 10,041 Reputation points
    2020-12-17T17:29:27.397+00:00

    @James Hart , Apologies for the delay in response. Try with this command for removing ghosted NICs,

    Get-AzNetworkInterface | where-object { $_.VirtualMachine -eq $null } | Remove-azNetworkInterface  
    

    If you want to list the unattached NICs then you can use this command,

    Get-AzNetworkInterface | where-object { $_.VirtualMachine -eq $null } | ft name  
    

    ----------

    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.

    0 comments No comments

  2. James Hart 1 Reputation point
    2020-12-18T10:44:22.367+00:00

    Hi @suvasara-MSFT

    Thanks for your response, however I have a slight issue with this.
    I don't think I am able to do that as I don't the Azure cloud shell on my account.
    It is from a free trial period, which has expired this morning, so I just want to remove the resource group and associated resources so we are not billed for them.

    Is there any alternative way to do this?

    Kind Regards,
    James

    0 comments No comments

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.