Azure WebApp, Microsoft Azure

Unable to delete a virtual network’s subnet due to serviceAssociationLinks and delegation

Error details

Failed to delete subnet 'subnet name'. Error: Subnet <subnet name> is in use by /subscriptions/<id>/resourceGroups/<rgname>/providers/Microsoft.Network/virtualNetworks/<vnetname>/subnets/<subnetname>/serviceAssociationLinks/AppServiceLink and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet.

The above error is due to a non-recommended steps/way of deletion of webapp. Following are the steps to be followed, to resolve such issues and to be able to delete the azure network components

  1. List the subnet list with the cli
    • az network vnet subnet list --resource-group <rg name> --vnet-name <vnet name>
  2. Find the SAL from the result from the tag “serviceAssociationLinks/link”
    • Example:  "/subscriptions/<sub name>/resourceGroups/<rg name>/providers/Microsoft.Web/serverfarms/<SALNAME>
  3. Create a new Web App under the same Subscription and Resource Group with same Web App name, type etc. which was deleted before
    • Make sure that under “Networking” tab, “Enable virtual network integration” is selected
    • Select the Virtual Network “Backends”
    • Under “Outbound access”, select “Enable Vnet integration”.
    • Selected the same subnet as used before
  4. After the deployment found successful, visit app service plan section
  5. Go to Settings>Networking>VNet Integration and select “Click here to manage”.
  6. Make sure that, “Regional VNet integrations” is 1/2, with VNet selected in previous attempt
  7. Under Settings>Networking>Outbound traffic configuration, disconnect the Virtual network integration

Above steps will help to delete the “serviceAssociationLinks”. Further, we can be able to remove the delegation from the subnet and delete it

Leave a Reply

Your email address will not be published. Required fields are marked *