We create our own Azure infrastructure in code, using PowerShell, and not ARM templates. We have a WebApp that is connected to a VNet, and we use the following cmdlet to set it up:
New-AzureRmResource -ResourceGroupName $ComputeResourceGroupName -Location $ComputeResourceGroupLocation
-Properties $PropertiesObject
-ResourceName "$($WebAppConf.Name)/$($VNet.Name)/primary"
-ResourceType "Microsoft.Web/sites/virtualNetworkConnections/gateways"
-ApiVersion 2015-08-01 -Force
For costs reasons, and since this is a testing machine, we turn off all the testing infrastructure every night, and up again every morning before the team starts working. This includes deleting the app service plan, and the web app included, and recreate it with a new build being deployed every morning. Again this is to save some costs for the better part of the day while no one is at the office or working. The issue we are facing is, when we tend to recreate the web app, and then reconnect the web app to the VNet, we always end up with a new connection instance as shown in the below screenshot. I know the answer seems obvious, that we can simply delete the old existing connection, and recreate it, but you can never get a handle of the connection instance, even after calling the Get-AzureRmResource, so apparently cant delete using PowerShell or even through the portal.
In other words, whenever you create a VNet Integration connection between a web app and a VNet, it stays there undeletable forever, even if you deleted both the web apps and the VNet. In addition, the new connection being created doesn’t work unless you select it, and clicked on the Sync Network button.