There are a couple of different approaches you can take when you want to delete a virtual network gateway for a VPN gateway configuration.
If you want to delete everything and start over, as in the case of a test environment, you can delete the resource group. When you delete a resource group, it deletes all the resources within the group. This is method is only recommended if you don't want to keep any of the resources in the resource group. You can't selectively delete only a few resources using this approach.
If you want to keep some of the resources in your resource group, deleting a virtual network gateway becomes slightly more complicated. Before you can delete the virtual network gateway, you must first delete any resources that are dependent on the gateway. The steps you follow depend on the type of connections that you created and the dependent resources for each connection.
To delete a virtual network gateway, you must first delete each resource that pertains to the virtual network gateway. Resources must be deleted in a certain order due to dependencies.
Step 1: Navigate to the virtual network gateway
- In the Azure portal, navigate to All resources.
- To open the virtual network gateway blade, navigate to the virtual network gateway that you want to delete and click it.
Step 2: Delete connections
- On the blade for your virtual network gateway, click Connections to view all connections to the gateway.
- Click the '...' on the row of the name of the connection, then select Delete from the dropdown.
- Click Yes to confirm that you want to delete the connection. If you have multiple connections, delete each connection.
Step 3: Delete the virtual network gateway
Be aware that if you have a P2S configuration to this VNet in addition to your S2S configuration, deleting the virtual network gateway will automatically disconnect all P2S clients without warning.
- On the virtual network gateway blade, click Overview.
- On the Overview blade, click Delete to delete the gateway.
At this point, the virtual network gateway is deleted. The next steps help you delete any resources that are no longer being used.
To delete the local network gateway
- In All resources, locate the local network gateways that were associated with each connection.
- On the Overview blade for the local network gateway, click Delete.
To delete the Public IP address resource for the gateway
- In All resources, locate the Public IP address resource that was associated to the gateway. If the virtual network gateway was active-active, you will see two Public IP addresses.
- On the Overview page for the Public IP address, click Delete, then Yes to confirm.
To delete the gateway subnet
- In All resources, locate the virtual network.
- On the Subnets blade, click the GatewaySubnet, then click Delete.
- Click Yes to confirm that you want to delete the gateway subnet.
If you are not concerned about keeping any of your resources in the resource group and you just want to start over, you can delete an entire resource group. This is a quick way to remove everything. The following steps apply only to the Resource Manager deployment model.
- In All resources, locate the resource group and click to open the blade.
- Click Delete. On the Delete blade, view the affected resources. Make sure that you want to delete all of these resources. If not, use the steps in Delete a VPN gateway at the top of this article.
- To proceed, type the name of the resource group that you want to delete, then click Delete.