Are there any way to disconnect an App Service from a subnet in a virtual network using arm templates?

Mads Grunnet 1 Reputation point
2020-11-20T13:53:09.593+00:00

Are there any way to disconnect an App Service from a subnet in a virtual network using arm templates?

I am integrating App Service with a subnet in a virtual network using an armtemplate.
In some rare cases I need to be able to disconnect the App Service from the subnet again also using arm templates, however, I have not been able to find support to achieve this. Have I missed an obvious solution to achieve this, or is it not possible?

The arm template is deployed incrementally. Using Powershell or Azure CLI are unfortunately not an option in my case.

I am using the below arm template (snippet) to integrate the App Service in the subnet (see attached doc for full example: 41472-deployverify-managednatjson.txt).

    {  
      "name": "[variables('webAppName')]",  
      "type": "Microsoft.Web/sites",  
      "apiVersion": "2018-11-01",  
      "location": "[variables('location')]",  
      "tags": {  
      },  
      "dependsOn": [  
        "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",  
        "[resourceId('Microsoft.Network/virtualNetworks', variables('vNetName'))]"  
      ],  
      "properties": {  
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",  
        "siteConfig": {  
          "http20Enabled": true,  
          "minTlsVersion": "1.2",  
          "vnetRouteAllEnabled": true  
        },  
        "httpsOnly": false  
      },  
      "resources": [  
        {  
          "name": "virtualNetwork",  
          "type": "networkConfig",  
          "apiVersion": "2018-11-01",  
          "location": "[variables('location')]",  
          "properties": {  
            "subnetResourceid": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'), 'outbound')]",  
            "swiftSupported": true  
          },  
          "dependsOn": [  
            "[resourceId('Microsoft.Web/sites', variables('webAppName'))]"  
          ]  
        }  
      ]  
    }  

Thanks, Mads

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,780 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 28,191 Reputation points Microsoft Employee
    2020-11-23T03:08:35.8+00:00

    Hi @Mads Grunnet ,

    You'll have to deploy your ARM template in complete mode rather than incremental which is the default. That will delete resources that aren't specified in your template. If your existing vnet is used for other services though, then this may won't work for you. Do make sure though you run the what-if operation to ensure you're not removing some other dependent resources. If what-if shows that a resource will be deleted that you would rather have disassociated, then you may have to use the portal to perform the disassociation or recreate the resources in a separate template deployment.

    Regards,
    Ryan


Your answer

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