Skip to main content

Prepare the network

The module does not create the virtual network, its subnets or its private DNS zones: you pass their ids. This page lists what it needs and which input takes each. The complete example creates all of them, and is a working starting point.

The subnets​

SubnetDelegated toSizeInput
One per slot, for its environmentMicrosoft.App/environmentsa /27 at leastslots.<slot>.infrastructure_subnet_id
The database'sMicrosoft.DBforPostgreSQL/flexibleServersAzure's minimum for itpostgres.delegated_subnet_id
Private endpointsnothingroom for one or twokey_vault.private_endpoint_subnet_id, storage.private_endpoint_subnet_id

Each slot needs its own subnet: one subnet holds one Container Apps environment, and the plan refuses two slots on the same one. The private endpoints of the Key Vault and of the storage account can share a subnet, as they do in the complete example.

In Terraform, a delegation is a block on the subnet:

resource "azurerm_subnet" "apps_blue" {
name = "snet-apps-blue"
resource_group_name = "rg-network-example"
virtual_network_name = "vnet-example"
address_prefixes = ["10.40.0.0/23"]

delegation {
name = "container-apps"
service_delegation {
name = "Microsoft.App/environments"
actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
}
}
}

The private DNS zones​

ZoneForInput
a name ending in .postgres.database.azure.comthe database serverpostgres.private_dns_zone_id
privatelink.vaultcore.azure.netthe Key Vault's endpointkey_vault.private_dns_zone_id
privatelink.blob.core.windows.netthe storage account's endpoint, with storage onstorage.private_dns_zone_id

Link each zone to the virtual network, with azurerm_private_dns_zone_virtual_network_link, before the module creates the server and the endpoints: they register in the zones and resolve through them. The complete example says so with depends_on on its module call. The plan refuses a database zone whose name does not end in .postgres.database.azure.com.

Let senders reach the engine​

By default each slot's environment has an internal load balancer: a private address in its subnet, and no public address. The slots output gives it as static_ip. Senders on the virtual network, or on a network peered or connected with it, connect there on the MLLP ports.

ingress_allowed_cidrs names the ranges allowed to connect; every other address is denied. Leave it empty to allow everything that can route to the private address, or name your senders' ranges. Senders on the internet need a public environment, internal_load_balancer_enabled = false, and then the plan refuses an empty ingress_allowed_cidrs: Deployment shapes says what that opens.

Give the apply a way into the Key Vault​

The Key Vault denies every network by default, and the apply writes the database URL secret into it, so the machine that runs terraform apply needs a way in. Either run it inside the virtual network (or a network peered with it), where the vault's private endpoint resolves, or set key_vault.public_network_access_enabled = true with key_vault.allowed_ip_ranges naming the runner's public address. The plan refuses a vault that nothing could reach.