0
votes

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.

Anyone has any ideas? enter image description here

1
If you then want to delete your VNET you need to first delete the resources in it including the gateways. in that case your vnet integration needs to be deleted right ?Aravind
I dont want to delete my VNet, I want to delete the app service plan.Ahmed IG

1 Answers

0
votes

For cost saving if you are deleting the Gateway in the VNet, then you are deleting all the connections along with it. When you recreate the gateway the next day morning, you have to recreate the connection. We do not preserve the connection when the gateway is deleted. On the other hand, if you retain the gateway, then the connections are also retained.