I am using app_service_virtual_network_swift_connection
to create Vnet Integration for an AppService.
resource "azurerm_app_service_virtual_network_swift_connection" "example" {
app_service_id = azurerm_app_service.example.id
subnet_id = azurerm_subnet.example.id
}
But I cant find way to enable the Application Routing
and Configuration Routing
settings as shown in picture. Is there way to enable all the checkboxes via a Terraform resource?
Firstly, to enable the Application Routing under virtual network integration of a web app, you need to enable the site configuration property vnet_route_all_enabled = true
as given here.
Refer terraform registry for basic template.
Complete Terraform code:
provider "azurerm"{
features{}
subscription_id = "xxxx"
}
resource "azurerm_resource_group" "example" {
name = "newresources"
location = "West Europe"
}
resource "azurerm_virtual_network" "example" {
name = "jah-network"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_subnet" "example" {
name = "defsubnet"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.0.1.0/24"]
delegation {
name = "example-delegation"
service_delegation {
name = "Microsoft.Web/serverFarms"
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
}
}
}
resource "azurerm_service_plan" "main" {
location = azurerm_resource_group.example.location
name = "ASP-webapprg"
os_type = "Windows"
resource_group_name = azurerm_resource_group.example.name
sku_name = "P1v3"
}
resource "azurerm_windows_web_app" "main" {
name = "jahwebappdemo"
location = azurerm_resource_group.example.location
public_network_access_enabled = false
resource_group_name = azurerm_resource_group.example.name
service_plan_id = azurerm_service_plan.main.id
virtual_network_subnet_id = azurerm_subnet.example.id
webdeploy_publish_basic_authentication_enabled = false
client_affinity_enabled = true
ftp_publish_basic_authentication_enabled = false
https_only = true
site_config {
ftps_state = "FtpsOnly"
vnet_route_all_enabled = true
}
}
When it comes to Configuration Routing in virtual network integration, it seems there is no exact site property available in terraform. Alternatively, I have used below CLI commands to make it work as expected apart from the Portal approach.
az resource update --resource-group newresources --name jahwebappdemo --resource-type "Microsoft.Web/sites" --set properties.vnetImagePullEnabled=true
az resource update --resource-group newresources --name jahwebappdemo --resource-type "Microsoft.Web/sites" --set properties.vnetContentShareEnabled=true
az resource update --resource-group newresources --name jahwebappdemo --resource-type "Microsoft.Web/sites" --set properties.vnetBackupRestoreEnabled=true