Vnet deletion error: InUseSubnetCannotBeDeleted

Ezekiel Stone 10 Reputation points
2023-05-05T04:14:19.12+00:00

Service: Vnet

Operation: Delete

Error: InUseSubnetCannotBeDeleted

/subscriptions/c511dddf-09cc-4b7e-8ce6-0990856101b0/resourceGroups/GlassCaldher/providers/Microsoft.Network/virtualNetworks/glasscaldh-99ee0574dd-vnet/subnets/glasscaldh-9806365fc9-appsubnet/serviceAssociationLinks/AppServiceLink está usando la subred glasscaldh-9806365fc9-appsubnet y no se puede eliminar.

No se pudo eliminar la subred "glasscaldh-9806365fc9-appsubnet". Error: glasscaldh-99ee0574dd-vnet/glasscaldh-9806365fc9-appsubnet/AppServiceLink está usando la subred glasscaldh-9806365fc9-appsubnet y no se puede eliminar.

I tried all the possible solutions on the forums and Q&A post related but still cant delete that resource. I need technical help please.

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,762 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,933 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. KapilAnanth-MSFT 49,536 Reputation points Microsoft Employee Moderator
    2023-05-05T12:42:37.9033333+00:00

    @Ezekiel Stone

    This happens when you delete an App Service integrated into the VNet without removing the integration.

    Reason for this Error:
    The VNET integration feature must set locks on subnets in the Network Resource Provider, we set these locks by putting a structure called a Service Association Link(SAL) onto the Subnet, which is a privileged operation that only Microsoft.Web and some other internal Azure services have access to, this ends up being odd cases where these locks don't get cleaned up. The result is that the customer will have a subnet that cannot be deleted or used because a Service Association Link still exists on the subnet.

    To delete this SAL from your end,

    1. Create App Service Plan with the same name as the deleted one
    2. Create App Service with the same name as the deleted one
    3. Link App Service with the VNET subnet
    4. Disconnect VNet from App Service -> Networking -> VNet integration -> Disconnect
    5. Delete subnet
    6. Then delete the AppService

    In case the work around did not help

    To delete this SAL, we will need a specialized 1:1 session, where a support engineer can delete this lock. If you have a support plan you may file a support ticket, else please do let us know, we will try and help you get a one-time free technical support.

    Cheers,

    Kapil


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

    1 person found this answer helpful.

  2. RevelinoB 3,675 Reputation points
    2023-05-05T04:28:42.18+00:00

    Hi Ezekiel,

    When I look at the error message you provided, it appears that you are trying to delete a subnet named "glasscaldh-9806365fc9-appsubnet" within a virtual network named "glasscaldh-99ee0574dd-vnet". However, the deletion is failing because there is a service association link (AppServiceLink) that is currently using this subnet. Due to this dependency, the subnet cannot be deleted.

    To fix this issue, you need to remove the association between the AppServiceLink and the subnet before attempting to delete the subnet again. Here are the steps you can follow:

    1. Identify the AppServiceLink that is associated with the subnet "glasscaldh-9806365fc9-appsubnet". You can find this information in the Azure portal or by using Azure CLI or Azure PowerShell.
    2. Once you have identified the AppServiceLink, you need to remove the association. Depending on the type of resource associated with the link, there are different ways to do this:

    If it is an Azure App Service, you can go to the App Service settings in the Azure portal, navigate to the Networking section, and remove the VNet integration configuration that references the subnet.

    If it is an Azure Function App, you can follow similar steps as for the App Service, but in the Function App settings.

    If it is a different type of resource, refer to the documentation specific to that resource to find the steps for removing the VNet integration or service association.

    After removing the association, wait for a few minutes to ensure that the changes propagate.

    Try deleting the subnet "glasscaldh-9806365fc9-appsubnet" again. It should now be possible to delete the subnet successfully.

    If you have checked these steps and are still experiencing issues, please provide additional details about the specific resources involved (such as the type of service associated with the subnet) so that I can assist you further?


  3. TP 124.7K Reputation points Volunteer Moderator
    2023-05-05T05:54:53.4833333+00:00

    Hi,

    In the Azure portal, please open the Virtual Network, click on Subnets blade, then click on glasscaldh-9806365fc9-appsubnet. Under Subnet Delegation, change it from Microsoft.Web/serverFarms to None, click Save. Similar to screenshot below:

    azure vnet subnet delegation

    After completing the above please test to see if you can delete the VNet. It may not allow you to remove the delegation. If it gives you an error, please leave a comment.

    Thanks.

    -TP


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.