Forum Discussion

slhicham's avatar
slhicham
Copper Contributor
Jul 31, 2024

Delete WebApp

Hi,

I'm having trouble deleting an App Service that has VNet Integration enabled. The problem arises because the VNet has been removed, and the deletion process can't find the Subnet linked to the App Service. Could you please help me delete this App Service?

 

Here is the error message : 
An operation on the Virtual Network has failed. Details: {"error":{"code":"ResourceNotFound","message":"The Resource 'Microsoft.Network/virtualNetworks/vnet-ep45iv7w5ymp4' under resource group 'rg-rg-demo-openai' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"}}

 

 

 

  •  Hi slhicham

    Deleting an App Service with VNet Integration can be tricky, especially if the associated VNet has already been removed. The App Service's association with the missing VNet may cause errors during the deletion process, as you've encountered. Here are steps you can follow to resolve this issue and delete the App Service:

    Steps to Resolve the Issue

    1. Remove VNet Integration from the App Service

      Even though the VNet is no longer available, the App Service might still think it's integrated with it. You can try removing the VNet Integration configuration from the App Service via Azure CLI or the Azure Portal.

      Using Azure CLI:

      az webapp vnet-integration remove --name <AppServiceName> --resource-group <ResourceGroupName>

      Replace <AppServiceName> and <ResourceGroupName> with your App Service name and the resource group name.

    2. Remove Site Configuration

      If the above step doesn't work, you may need to clear out the VNet integration settings directly from the site configuration using the Azure CLI.

      az resource update --ids $(az webapp show --name <AppServiceName> --resource-group <ResourceGroupName> --query id --output tsv) --remove properties.siteConfig.vnetRouteAllEnabled

      This command removes the VNet routing configuration from the App Service.

    3. Force Delete the App Service

      Once the VNet Integration configuration is removed, you can attempt to delete the App Service again.

      Using Azure CLI:

      az webapp delete --name <AppServiceName> --resource-group <ResourceGroupName>
    4. Clean Up Resources

      After successfully deleting the App Service, ensure no leftover resources related to the App Service or VNet remain in the resource group.

    Alternative Approach

    If the above steps don't work, you can attempt to delete the App Service using the Azure REST API or by contacting Microsoft support to forcefully remove the resource.

    • slhicham's avatar
      slhicham
      Copper Contributor
      Thank you for your help.
      I tried all the commands without success to delete my web app. I can't contact Microsoft Support because my subscription does not allow me to create a support ticket. Is there any way to request Microsoft to delete my resources?
      • abhijeetdasgupta's avatar
        abhijeetdasgupta
        Copper Contributor

        Hi slhicham,

        I am afraid i am not aware of any other way to request Microsoft to delete the resources other than having the necessary support subscription.

        Although can you try the below to see if they help:

        1. Try Azure Resource Explorer:

        • Navigate to Azure Resource Explorer and find your App Service. You can attempt to manually remove or edit properties that are causing issues (like VNet integration) and then delete the resource.
        • To delete, navigate to the resource's JSON view and look for the "Delete" button.

        2. Try to Delete via PowerShell:

        • You might try using PowerShell commands as an alternative to Azure CLI:
          Remove-AzWebApp -ResourceGroupName <ResourceGroupName> -Name <AppServiceName> -Force
        • This command may bypass some of the issues encountered with the Azure CLI.

        3. Try Azure Portal Automation Script:

        • In the Azure Portal, go to your App Service and look for the "Automation Script" option. This provides a JSON template that describes your resource.
        • You can attempt to download the script, modify it (removing problematic dependencies like VNet integration), and then reapply the script to update or delete the resource.

        4. Try Azure REST API:

        5. Try to Recreate the VNet and Subnet:

        • Another potential workaround is to recreate the missing VNet and Subnet with the same names and configurations. Once recreated, you can attempt to remove the VNet integration from the App Service and then delete it.


        Do give these a try and see if they work for you

         

Resources