An Azure service that enables the connection of on-premises networks to Azure through site-to-site virtual private networks.
Hello @MJK-6582
The public IP and GatewaySubnet dependencies can’t normally be removed while the virtual network gateway still exists. The resources must be deleted in dependency order.
First, check the Activity log on the gateway and identify the operation that placed it in the Failed state. Save the error details, timestamp, and correlation ID. Also check for ReadOnly or CanNotDelete locks on the gateway, resource group, and subscription. Resource locks override normal RBAC permissions.
A failed Microsoft.Network provisioning state can sometimes be cleared by submitting a PUT operation with the resource’s current configuration:
$gateway = Get-AzVirtualNetworkGateway `
-Name "<gateway-name>" `
-ResourceGroupName "<resource-group>"
$gateway | Set-AzVirtualNetworkGateway
After it completes, confirm the state:
(Get-AzVirtualNetworkGateway `
-Name "<gateway-name>" `
-ResourceGroupName "<resource-group>").ProvisioningState
This operation resubmits the existing gateway configuration; review the current object before running it. GET/SET is a method for restoring a failed virtual network gateway to Succeeded.
Once the gateway is no longer stuck, delete the resources in this order:
- Delete every connection associated with the gateway.
- Delete the virtual network gateway.
- Delete any unused local network gateway.
- Delete the now-detached public IP address.
- Delete GatewaySubnet only if it’s no longer required.
Azure CLI example:
az network vpn-connection delete \
--resource-group "<resource-group>" \
--name "<connection-name>"
az network vnet-gateway delete \
--resource-group "<resource-group>" \
--name "<gateway-name>"
Deleting the resource group is another option only if every resource inside it can be removed. Don’t use that approach if the resource group contains workloads that must be retained.
If the GET/SET operation and deletion both fail with InternalServerError, Conflict, or another provider-side error, there isn’t a documented customer-side force-delete mechanism for a stuck gateway. Open an Azure support request and include the subscription ID, gateway resource ID, UTC timestamp, exact error, and correlation ID so the Microsoft.Network team can repair or remove the resource from the backend.
References:
- Troubleshoot failed provisioning states for Microsoft.Network resources
- Delete an Azure VPN gateway using PowerShell
- Delete an Azure VPN gateway using the portal
- Azure CLI: virtual network gateway commands
- Azure resource locks
Help make this community better for everyone: If this answer helped or resolved your issue, please accept it or upvote it. If not, share more details in a comment so we can continue the discussion and find the right solution. Thank you.