Azure App Service (Web Apps) Virtual Network Swift Connection

This page shows how to write Terraform and Azure Resource Manager for App Service (Web Apps) Virtual Network Swift Connection and write them securely.

azurerm_app_service_virtual_network_swift_connection (Terraform)

The Virtual Network Swift Connection in App Service (Web Apps) can be configured in Terraform with the resource name azurerm_app_service_virtual_network_swift_connection. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

webapp_virtual_network.tf#L1
resource "azurerm_app_service_virtual_network_swift_connection" "webapp" {
  app_service_id = module.webapp.webapp_service_id
  subnet_id      = azurerm_subnet.backend.id
}
webapp.tf#L36
resource "azurerm_app_service_virtual_network_swift_connection" "webapp" {
  app_service_id = azurerm_app_service.website.id
  subnet_id      = azurerm_subnet.web_se.id
webapp.tf#L36
resource "azurerm_app_service_virtual_network_swift_connection" "webapp" {
  app_service_id = azurerm_app_service.website.id
  subnet_id      = azurerm_subnet.web_se.id
main.tf#L7
resource "azurerm_app_service_virtual_network_swift_connection" "this" {
  app_service_id = var.app_service_id
  subnet_id      = var.subnet_id

  dynamic "timeouts" {
    for_each = var.timeouts
webapp.tf#L43
resource "azurerm_app_service_virtual_network_swift_connection" "vnet_integration" {
  app_service_id = azurerm_app_service.example.id
  subnet_id      = data.azurerm_subnet.web.id
}
main.tf#L7
resource "azurerm_app_service_virtual_network_swift_connection" "this" {
  app_service_id = var.app_service_id
  subnet_id      = var.subnet_id

  dynamic "timeouts" {
    for_each = var.timeouts
main.tf#L1
resource "azurerm_app_service_virtual_network_swift_connection" "example" {
  app_service_id = module.app_service.azurerm_app_service.example.id
  subnet_id      = module.subnet.azurerm_subnet.example.id
main.tf#L25
resource "azurerm_app_service_virtual_network_swift_connection" "main" {
  for_each       = var.func_apps
  app_service_id = azurerm_function_app.main[each.key].id
  subnet_id      = each.value.subnet_id
}
webapp.tf#L23
resource "azurerm_app_service_virtual_network_swift_connection" "vnet" {
  app_service_id = azurerm_app_service.appservice.id
  subnet_id      = azurerm_subnet.webapp.id
}
vm00.tf#L69
resource "azurerm_app_service_virtual_network_swift_connection" "vnetintegrationconnection" {
  app_service_id  = azurerm_app_service.frontwebapp.id
  subnet_id       = azurerm_subnet.integrationsubnet.id
}

resource "azurerm_app_service" "backwebapp" {

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages an App Service Virtual Network Association (this is for the Regional VNet Integration).

Note: This resource can be used for both azurerm_app_service and azurerm_function_app.

Note: There is a hard limit of one VNet integration per App Service Plan. Multiple apps in the same App Service plan can use the same VNet.

Tips: Best Practices for The Other Azure App Service (Web Apps) Resources

In addition to the azurerm_app_service, Azure App Service (Web Apps) has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_app_service

Ensure your App Service is accessible via HTTPS only

It is better to configure the App Service to be accessible via HTTPS only. By default, both HTTP and HTTPS are available.

risk-label

azurerm_function_app

Ensure to enable authentication to prevent anonymous request being accepted

It is better to enable authentication to prevent anonymous requests and ensure all communications in the application are authenticated.

Review your Azure App Service (Web Apps) settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Microsoft.Web/sites/virtualNetworkConnections (Azure Resource Manager)

The sites/virtualNetworkConnections in Microsoft.Web can be configured in Azure Resource Manager with the resource name Microsoft.Web/sites/virtualNetworkConnections. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

webapp-vnet.json#L22
        "type": "Microsoft.Web/sites/virtualNetworkConnections",
        "apiVersion": "2016-08-01",
        "name": "[concat(parameters('webapp'), '/',variables('vnet'))]",
        "location": "[resourceGroup().location]",

        "properties": {
VirtualNetworkServiceEndpoint_AppService_AuditIfNotExists.json#L41
          "type": "Microsoft.Web/sites/virtualNetworkConnections",
          "existenceCondition": {
            "field": "Microsoft.Web/sites/virtualnetworkconnections/vnetResourceId",
            "exists": "true"
          }
        }
policy.json#L41
     "type": "Microsoft.Web/sites/virtualNetworkConnections",
     "existenceCondition": {
      "field": "Microsoft.Web/sites/virtualnetworkconnections/vnetResourceId",
      "exists": "true"
     }
    }
asp-require-vnet-integration.json#L42
                    "type": "Microsoft.Web/sites/virtualNetworkConnections",
                    "existenceCondition": {
                        "field": "Microsoft.Web/sites/virtualnetworkconnections/vnetResourceId",
                        "exists": "true"
                    }
                }
VirtualNetworkServiceEndpoint_AppService_AuditIfNotExists.json#L41
          "type": "Microsoft.Web/sites/virtualNetworkConnections",
          "existenceCondition": {
            "field": "Microsoft.Web/sites/virtualnetworkconnections/vnetResourceId",
            "exists": "true"
          }
        }
policy.json#L41
     "type": "Microsoft.Web/sites/virtualNetworkConnections",
     "existenceCondition": {
      "field": "Microsoft.Web/sites/virtualnetworkconnections/vnetResourceId",
      "exists": "true"
     }
    }
policy.json#L41
     "type": "Microsoft.Web/sites/virtualNetworkConnections",
     "existenceCondition": {
      "field": "Microsoft.Web/sites/virtualnetworkconnections/vnetResourceId",
      "exists": "true"
     }
    }
virtualnetworkconnections.json#L3
  "type": "Microsoft.Web/sites/virtualNetworkConnections",
  "apiVersion": "2018-11-01",
  "kind": "string",
  "properties": {
    "vnetResourceId": "string",
    "certBlob": "string",
policy.json#L41
     "type": "Microsoft.Web/sites/virtualNetworkConnections",
     "existenceCondition": {
      "field": "Microsoft.Web/sites/virtualnetworkconnections/vnetResourceId",
      "exists": "true"
     }
    }
VirtualNetworkServiceEndpoint_AppService_AuditIfNotExists.json#L41
          "type": "Microsoft.Web/sites/virtualNetworkConnections",
          "existenceCondition": {
            "field": "Microsoft.Web/sites/virtualnetworkconnections/vnetResourceId",
            "exists": "true"
          }
        }

Parameters

  • apiVersion required - string
  • kind optional - string

    Kind of resource.

  • name required - string

    Name of an existing Virtual Network.

  • properties required
      • certBlob optional - string

        A certificate file (.cer) blob containing the public key of the private key used to authenticate a Point-To-Site VPN connection.

      • dnsServers optional - string

        DNS servers to be used by this Virtual Network. This should be a comma-separated list of IP addresses.

      • isSwift optional - boolean

        Flag that is used to denote if this is VNET injection

      • vnetResourceId optional - string

        The Virtual Network's resource ID.

  • type required - string

Frequently asked questions

What is Azure App Service (Web Apps) Virtual Network Swift Connection?

Azure App Service (Web Apps) Virtual Network Swift Connection is a resource for App Service (Web Apps) of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure App Service (Web Apps) Virtual Network Swift Connection?

For Terraform, the nhs-digital-gp-it-futures/GPITBuyingCatalogue, fortunkam/asev3-firewall-appgateway and fortunkam/webapp-privatelink source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the scoutzfiction/arm-templates, Prathyusha-91/azure-policy and induxsi/Test source code examples are useful. See the Azure Resource Manager Example section for further details.