Unable to delete Loadbalancer beceause it is being used by an already deleted VMSS

Hanno 0 Reputation points
2024-09-30T08:12:17.4266667+00:00

When trying to delete a loadbalancer in Azure, I get an error saying that it cannot be removed because it is being used by a Virtual machine Scale Set. However the VMSS is already deleted, it seems that the dependency still exists pointing to a dead resource. I tried various troubleshooting steps, including

  • checking if the vmss is actually deleted through azure cli
  • force deleting via cli, including Back-End-Pools
  • deleting all outbound rules

I also tried these steps which seemed to have helped other users experiencing this issuse:

Remove load balancer associated with the VMSS: `az vmss update --resource-group <

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,991 questions
Azure Load Balancer
Azure Load Balancer
An Azure service that delivers high availability and network performance to applications.
450 questions
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

1 answer

Sort by: Most helpful
  1. anashetty 585 Reputation points Microsoft Vendor
    2024-09-30T16:48:45.5066667+00:00

    Hi Hanno,

    Based on the error details you shared, I have shared troubleshooting steps that I felt will help resolve the issue you reported.

    If the Load Balancer resource is in use by a Virtual Machine Scale Set and can't be deleted. Use the Azure Resource Manager ID provided in the error message to search for the Virtual Machine Scale Set in order to delete it.

    Check if there are any remaining resources linked to the load balancer that might prevent its deletion:

    List Network Interfaces: az network nic list --query "[].{Name:name, IPConfigs:ipConfigurations[].{Name:name, LBBackendPools:loadBalancerBackendAddressPools[].id}}"

    Check Load Balancer Health Probes: az network lb probe list -g <<RESOURCE_GROUP_NAME>> --lb-name <<LB_NAME>>

    Check the Load Balancer details: az network lb show -g <<RESOURCE_GROUP_NAME>> -n <<LB_NAME>>

    If you find any dependencies, remove them manually by using the following commands:

    For Backend Address Pool: az network lb backend-pool remove --resource-group <<RESOURCE_GROUP_NAME>> --lb-name <<LB_NAME>> --name <<BACKEND_POOL_NAME>> --backend-addresses <ADDRESS>

    To remove Load Balancer Rules: az network lb rule delete --resource-group <<RESOURCE_GROUP_NAME>> --lb-name <<LB_NAME>> --name <<RULE_NAME>>

    You can also check the dependencies using the Azure Resource Explorer: Go to the Azure Resource Explorer. then Navigate to the load balancer resource and check the JSON properties for any references to the VMSS or other resources that may still exist. If you find any stale references, you can delete them directly from Resource Explorer.

    Please let us know if you have any further queries. I’m happy to assist you further.


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.