Unable to delete the subnet in Azure

Deepak sundaram 106 Reputation points
2020-08-25T06:18:26.15+00:00

My resource group is in centralUS and I created a VM in Japan East. In the resource group, I selected all the resources and deleted but few resources like Disk, NIC, NSG, VNET are not been deleted. Getting the below error messages

Error messges;

Failed to delete subnet 'pointersubnet'. Error: Subnet pointersubnet is in use by River-Dale/providers/Microsoft.Network/networkInterfaces/desktop729/ipConfigurations/ipconfig1'>desktop729/ipconfig1 and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.

Failed to delete virtual network 'pointers'. Error: Subnet pointersubnet is in use by River-Dale/providers/Microsoft.Network/networkInterfaces/desktop729/ipConfigurations/ipconfig1'>desktop729/ipconfig1 and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.

Failed to delete network interface 'desktop729'. Error: Network Interface River-Dale/providers/Microsoft.Network/networkInterfaces/desktop729'>desktop729 is used by existing resource /subscriptions/ef4b4581-7ba0-4490-94ee-f33d39fb61cb/resourceGroups/River-Dale/providers/Microsoft.Compute/virtualMachines/Desktop. In order to delete the network interface, it must be dissociated from the resource. To learn more, see aka.ms/deletenic.

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,425 questions
0 comments No comments
{count} vote

Accepted answer
  1. Deepak sundaram 106 Reputation points
    2020-08-26T04:39:34.7+00:00

    I reached out to support request and they asked me to execute the cmd I executed the cmd

    Remove-AzResourceGroup -Name [NAME OF RESOURCEGROUP] –Force

    But I received the error as below several times

    Remove-AzResourceGroup -Name River-Dale -ForceRemove-AzResourceGroup: Long running operation failed with status 'Conflict'.
    StatusCode: 409
    ReasonPhrase: Conflict
    OperationID :

    Post which I performed the below actions and then executed the cmd Remove-AzResourceGroup -Name [NAME OF RESOURCEGROUP] –Force and then it worked!!!! my resource group River-Dale got deleted.

    1. Created VM with the same name & region as the deleted one
    2. Associated the VNET (which I am unable to delete) to the created VM

    After that, I executed the cmd and it deleted my resource group

    1 person found this answer helpful.

4 additional answers

Sort by: Most helpful
  1. GitaraniSharma-MSFT 49,576 Reputation points Microsoft Employee
    2020-08-25T07:57:36.677+00:00

    Hello @Deepak sundaram ,

    Please try the below provided steps:

    Open a web browser and navigate to https://resources.azure.com
    Log-in to the appropriate Azure account
    In the blade on the left side of the browser, expand subscriptions, then expand the desired subscription name
    In the blade on the left side of the browser, expand resource groups
    Under resource groups, expand the proper Resource Group Name
    Under the Resource Group, expand providers
    Under providers, expand Microsoft.Network
    Under Microsoft.Network, expand networkinterfaces
    Under networkinterfaces, select the NIC which you are failing to delete.
    Near the top of the content window of the browser, select the Read/Write push button
    Select the Actions(POST, DELETE) tab and click on Delete.
    Once this NIC is deleted, you can retry to delete the ResourceGroup.
    If it does not succeed and you receive an error, please share the error for further investigation.

    Also, what output do you get when you run the below cmdlet:
    Get-AzVm -Name "Desktop" -ResourceGroupName "River-Dale"

    Alternatively, you may use the Azure PowerShell/CLI commands to remove the ResourceGroup. Please refer : https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/delete-resource-group?tabs=azure-powershell#delete-resource-group

    Kindly let us know if you need any further assistance on this issue from our end.

    ----------------------------------------------------------------------------------------------------------------

    Please don’t forget to "Accept the answer" wherever the information provided helps you, this can be beneficial to other community members.

    2 people found this answer helpful.

  2. Deepak sundaram 106 Reputation points
    2020-08-25T13:12:28.253+00:00

    Thanks for the response

    Below is the error message I am getting when I tried to delete the NIC

    {
    "error": {
    "code": "NicInUse",
    "message": "Network Interface /subscriptions/ef4b4581-7ba0-4490-94ee-f33d39fb61cb/resourceGroups/River-Dale/providers/Microsoft.Network/networkInterfaces/desktop729 is used by existing resource /subscriptions/ef4b4581-7ba0-4490-94ee-f33d39fb61cb/resourceGroups/River-Dale/providers/Microsoft.Compute/virtualMachines/Desktop. In order to delete the network interface, it must be dissociated from the resource. To learn more, see aka.ms/deletenic.",
    "details": []
    }
    }

    Power shell cmd: Get-AzVm -Name "Desktop" -ResourceGroupName "River-Dale"

    PS /home/deepak> Get-AzVm -Name "Desktop" -ResourceGroupName "River-Dale"
    Get-AzVM: The Resource 'Microsoft.Compute/virtualMachines/Desktop' under resource group 'River-Dale' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
    ErrorCode: ResourceNotFound
    ErrorMessage: The Resource 'Microsoft.Compute/virtualMachines/Desktop' under resource group 'River-Dale' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
    ErrorTarget:
    StatusCode: 404
    ReasonPhrase: Not Found
    OperationID : fa3c963a-9c71-46fb-9c64-1f553338c8c0


  3. Deepak sundaram 106 Reputation points
    2020-08-25T15:37:08.493+00:00

    I created a support request, will let you know the progress.

    Again thanks for your prompt reply & support

    0 comments No comments

  4. Deepak Bhardwaj 61 Reputation points
    2022-09-14T09:16:56.507+00:00

    Azure Resource Explorer

    {
    "name": "Solution_Unit-vnet",
    "id": "/subscriptions/7890e344-be6a-46e3-b94c-70a01769770c/resourceGroups/Solution_Unit/providers/Microsoft.Network/virtualNetworks/Solution_Unit-vnet",
    "etag": "W/\"1f8a7af7-4469-453b-9d80-2801831f58ac\"",
    "type": "Microsoft.Network/virtualNetworks",
    "location": "eastus",
    "tags": {},
    "properties": {
    "provisioningState": "Succeeded",
    "resourceGuid": "f51ac8d2-9a8d-4730-ab9f-bb273b85f863",
    "addressSpace": {
    "addressPrefixes": [
    "10.0.0.0/24",
    "(String)"
    ]
    },
    "subnets": [
    {
    "name": "default",
    "id": "/subscriptions/7890e344-be6a-46e3-b94c-70a01769770c/resourceGroups/Solution_Unit/providers/Microsoft.Network/virtualNetworks/Solution_Unit-vnet/subnets/default",
    "etag": "W/\"1f8a7af7-4469-453b-9d80-2801831f58ac\"",
    "properties": {
    "provisioningState": "Succeeded",
    "addressPrefix": "10.0.0.0/24",
    "serviceAssociationLinks": [
    {
    "name": "default-service-association-link",
    "id": "/subscriptions/7890e344-be6a-46e3-b94c-70a01769770c/resourceGroups/Solution_Unit/providers/Microsoft.Network/virtualNetworks/Solution_Unit-vnet/subnets/default/serviceAssociationLinks/default-service-association-link",
    "etag": "W/\"1f8a7af7-4469-453b-9d80-2801831f58ac\"",
    "type": "Microsoft.Network/virtualNetworks/subnets/serviceAssociationLinks",
    "properties": {
    "provisioningState": "Succeeded",
    "linkedResourceType": "",
    "enabledForArmDeployments": false,
    "allowDelete": false,
    "locations": []
    }
    }
    ],
    "serviceEndpoints": [],
    "delegations": [
    {
    "name": "Microsoft.DBforMySQL.flexibleServers",
    "id": "/subscriptions/7890e344-be6a-46e3-b94c-70a01769770c/resourceGroups/Solution_Unit/providers/Microsoft.Network/virtualNetworks/Solution_Unit-vnet/subnets/default/delegations/Microsoft.DBforMySQL.flexibleServers",
    "etag": "W/\"1f8a7af7-4469-453b-9d80-2801831f58ac\"",
    "properties": {
    "provisioningState": "Succeeded",
    "serviceName": "",
    "actions": [
    "Microsoft.Network/virtualNetworks/subnets/join/action"
    ]
    },
    "type": "Microsoft.Network/virtualNetworks/subnets/delegations"
    }
    ],
    "privateEndpointNetworkPolicies": "Disabled",
    "privateLinkServiceNetworkPolicies": "Enabled"
    },
    "type": "Microsoft.Network/virtualNetworks/subnets"
    },
    {
    "id": "(String)",
    "properties": {
    "addressPrefix": {},
    "addressPrefixes": {},
    "networkSecurityGroup": {},
    "routeTable": {},
    "natGateway": {},
    "serviceEndpoints": {},
    "serviceEndpointPolicies": {},
    "privateEndpoints": {},
    "ipConfigurations": {},
    "ipConfigurationProfiles": {},
    "ipAllocations": {},
    "resourceNavigationLinks": {},
    "serviceAssociationLinks": {},
    "delegations": {},
    "purpose": {},
    "provisioningState": {},
    "privateEndpointNetworkPolicies": {},
    "privateLinkServiceNetworkPolicies": {},
    "applicationGatewayIpConfigurations": {}
    },
    "name": "(String)",
    "etag": "(String)",
    "type": "(String)"
    }
    ],
    "virtualNetworkPeerings": [
    {
    "id": "(String)",
    "properties": {
    "allowVirtualNetworkAccess": {},
    "allowForwardedTraffic": {},
    "allowGatewayTransit": {},
    "useRemoteGateways": {},
    "remoteVirtualNetwork": {},
    "remoteAddressSpace": {},
    "remoteVirtualNetworkAddressSpace": {},
    "remoteBgpCommunities": {},
    "peeringState": {},
    "peeringSyncLevel": {},
    "provisioningState": {},
    "doNotVerifyRemoteGateways": {},
    "resourceGuid": {}
    },
    "name": "(String)",
    "etag": "(String)",
    "type": "(String)"
    }
    ],
    "enableDdosProtection": false,
    "dhcpOptions": {
    "dnsServers": [
    "(String)"
    ]
    },
    "flowTimeoutInMinutes": "(Integer)",
    "enableVmProtection": "(Boolean)",
    "ddosProtectionPlan": {
    "id": "(String)"
    },
    "bgpCommunities": {
    "virtualNetworkCommunity": "(String)",
    "regionalCommunity": "(String)"
    },
    "ipAllocations": [
    {
    "id": "(String)"
    }
    ]
    },
    "extendedLocation": {
    "name": "(String)",
    "type": "(String)"
    }
    }

    After trying to delete it getting the below error.

    {
    "error": {
    "code": "InUseSubnetCannotBeDeleted",
    "message": "Subnet default is in use by /subscriptions/7890e344-be6a-46e3-b94c-70a01769770c/resourceGroups/Solution_Unit/providers/Microsoft.Network/virtualNetworks/Solution_Unit-vnet/subnets/default/serviceAssociationLinks/default-service-association-link and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.",
    "details": []
    }
    }


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.