Issue with Resource Creation After Deletion in Azure Subscription

HarithasanR 0 Reputation points
2025-10-04T08:00:30.9766667+00:00

I have successfully created Application Gateway via ARM template in the UK South region, but after deleting a resource and attempting to create it again with a different or the same name, I consistently receive an internal server error. This issue persists even after waiting for some time and trying various unique names.

Could you please assist in identifying the root cause and provide guidance on resolving this problem?

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
{count} votes

2 answers

Sort by: Most helpful
  1. Salamat Shah 95 Reputation points MVP
    2025-10-04T10:48:53.7533333+00:00

    When creating any resource using a template, ensure that all the required dependent resources (e.g., Private Endpoints, VNet Peering, NSGs, etc.) are also created. If you encounter issues, verify that all associated resources have been deleted successfully before retrying the deployment.

    As a best practice, always create resources within a separate resource group. This makes it easier to track, manage, and clean up associated components..

    0 comments No comments

  2. Harish Peddapally 1,330 Reputation points Microsoft External Staff Moderator
    2025-10-06T05:25:13.2333333+00:00

    Hi HarithasanR,

    Welcome to Microsoft Q&A and thank you for posting your query here!

    When you delete an Azure Application Gateway and then attempt to create it again in the same subscription (even with a different or the same name), encountering an internal server error usually indicates that some resources or dependencies from the previously deleted gateway still exist or are not fully released. This is a common cause of deployment failures in Azure.

    Step-by-step guidance to identify and resolve the issue:

    1. Check for Orphaned Resources: After deleting the Application Gateway, verify that no related resources remain in the resource group. These could include:
      • Public IP addresses
      • Load Balancers (especially internal load balancer associated with the gateway)
      • Backend address pools or listeners
      • Managed identities or API connections You can do this via the Azure Portal or Azure CLI/PowerShell commands. Remove any leftover resources manually if found. Reference: Troubleshoot common Azure deployment errors
    2. Wait for Azure Backend Cleanup: Azure may take some time (often 15-30 minutes or longer) to fully clean up and release all the resources and locks after deletion. Trying to redeploy immediately can result in errors due to lingering locks or resources still being removed in the backend. Reference: Azure Application Gateway FAQ
    3. Validate the Subnet Usage: The subnet used by the Application Gateway (typically named ApplicationGatewaySubnet) must be free from other network resources that might block redeployment. Check that the subnet does not have any references or locks from the deleted gateway. Use Azure Portal or CLI to inspect subnet associations. Reference: Microsoft.Network/applicationGateways - ARM Template Docs
    4. Use Unique Names and Clean Resource Groups: To isolate issues related to name conflicts or resource locks, try deploying the Application Gateway with a new name in a new resource group and subnet. This helps identify if the issue is due to residual resources tied to old names or resource groups.
    5. Clear Hidden Dependencies with Azure CLI/PowerShell: Use commands like Get-AzResource to list resources and Remove-AzApplicationGateway -Force to forcibly remove stuck Application Gateway instances or related lingering resources. This can clear hidden dependencies not visible in the portal. Example:
         Get-AzResource -ResourceType "Microsoft.Network/applicationGateways"  
         Remove-AzApplicationGateway -Name <AppGatewayName> -ResourceGroupName <ResourceGroup> -Force"  
      

    i hope this will resolve your concern, please do let me know if you have any questions on this.

    If you found the answer helpful, it would be great if you please mark it "Accept as answer". This will help others to find answers in Q&A.

    Thanks,

    Harish.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.