Several Container Apps network settings are fixed when the environment is created: the VNet, the subnet and its size, and whether the environment is internal. Getting one wrong means rebuilding the environment and migrating every app. The rest of this list covers the faults seen most after go-live: internal apps nobody can resolve, image pulls blocked by forced tunnelling, and egress IPs that change.
Work through it before az containerapp env create, then again before the first production app.
Decide before you create the environment
| Decision | Can change later? | Recommendation |
|---|---|---|
| Environment type | No | Workload profiles. Consumption-only environments don't support UDR or NAT Gateway |
| VNet and subnet | No | A dedicated subnet, delegated to Microsoft.App/environments |
| Subnet size | No | /27 is the documented minimum for workload profiles; use /24 or larger for production |
| Internal or external ingress | No | Internal for anything behind Front Door, Application Gateway or a firewall |
| Zone redundancy | No | On, in regions with zones; check that the profiles you plan support it |
- Subnet sized for the peak, plus upgrades. The platform reserves some addresses in the subnet, and each node on a Dedicated profile takes one IP. Consumption profile usage grows with scale. Add headroom for platform upgrades, which can add capacity for a while. Work out the peak from max nodes per profile across all profiles, then double it.
- Subnet used only by this environment. No VMs, private endpoints or other delegations. Private endpoints for the apps' dependencies go in a separate subnet.
- Address range doesn't overlap with on-premises, peered VNets or the platform's internal ranges. Check the documented reserved ranges for Container Apps before choosing.
az network vnet subnet create -g rg-aca-net --vnet-name vnet-spoke-apps \
-n snet-aca-prod --address-prefixes 10.42.8.0/23 \
--delegations Microsoft.App/environments
SUBNET_ID=$(az network vnet subnet show -g rg-aca-net --vnet-name vnet-spoke-apps \
-n snet-aca-prod --query id -o tsv)
az containerapp env create -g rg-aca -n cae-prod -l westeurope \
--infrastructure-subnet-resource-id "$SUBNET_ID" \
--internal-only true \
--enable-workload-profiles \
--zone-redundant \
--logs-destination log-analytics \
--logs-workspace-id "$LAW_CUSTOMER_ID" --logs-workspace-key "$LAW_KEY"
On recent CLI versions workload profiles are the default, and --enable-workload-profiles may be implied. Check az containerapp env create --help.
Workload profiles
- Dedicated profiles for steady or memory-heavy apps; Consumption for spiky ones. Set min and max nodes deliberately. Max nodes is what your subnet must hold.
az containerapp env workload-profile add -g rg-aca -n cae-prod \
--workload-profile-name d4-general --workload-profile-type D4 \
--min-nodes 2 --max-nodes 10
az containerapp env workload-profile list -g rg-aca -n cae-prod -o table
- Min nodes of at least 2 on Dedicated profiles that run production apps, so a node upgrade doesn't take an app to zero.
Private DNS for an internal environment
An internal environment gets a private static IP and a default domain. Nothing creates DNS records for it. Until you do, apps are unreachable by name from outside the environment.
- Private DNS zone named after the environment's default domain, with a wildcard and an apex record pointing at the static IP:
read DOMAIN STATIC_IP < <(az containerapp env show -g rg-aca -n cae-prod \
--query "[properties.defaultDomain, properties.staticIp]" -o tsv | tr '\n' ' ')
az network private-dns zone create -g rg-dns -n "$DOMAIN"
az network private-dns record-set a add-record -g rg-dns -z "$DOMAIN" -n '*' -a "$STATIC_IP"
az network private-dns record-set a add-record -g rg-dns -z "$DOMAIN" -n '@' -a "$STATIC_IP"
az network private-dns link vnet create -g rg-dns -z "$DOMAIN" -n link-hub \
-v "$HUB_VNET_ID" -e false
- Zone linked where the clients resolve from. That is the hub VNet if spokes or on-premises resolve through a DNS Private Resolver in the hub, not only the spoke VNet.
- On-premises forwarders send the environment's domain to the resolver's inbound endpoint.
- Custom domains on apps (
az containerapp hostname add) also need records in whichever zone serves that domain internally.
Check from a VM in a different VNet:
dig +short myapi.$DOMAIN
curl -sk -o /dev/null -w "%{http_code}\n" "https://myapi.$DOMAIN/healthz"
Egress: UDR to Azure Firewall or NAT Gateway
- Pick one egress design. NAT Gateway on the subnet gives fixed outbound IPs that partners can allowlist. A UDR with
0.0.0.0/0to Azure Firewall gives central inspection. Both are supported on workload profiles environments only. - Firewall allows what the platform needs. With forced tunnelling, missing rules show up as image pull failures, revisions stuck provisioning, or no logs. At minimum, allow:
| Destination | Why |
|---|---|
Microsoft Container Registry (mcr.microsoft.com and its data endpoints) | Platform and system images |
| Your ACR login and data endpoints (or its private endpoint) | App images |
Microsoft Entra ID (AzureActiveDirectory service tag) | Managed identity tokens |
Azure Monitor (AzureMonitor service tag) | Logs and metrics |
| Key Vault, Storage, Service Bus or private endpoints the apps use | App dependencies |
The full and current list of FQDNs and service tags is in the Container Apps firewall documentation. Copy it from there into the firewall policy as an application rule collection, and review it whenever you change CLI or platform versions.
az network firewall policy rule-collection-group collection add-filter-collection \
-g rg-hub --policy-name afwp-hub --rule-collection-group-name rcg-aca \
--name allow-aca-platform --collection-priority 200 --action Allow \
--rule-type ApplicationRule --rule-name mcr \
--source-addresses 10.42.8.0/23 --protocols Https=443 \
--target-fqdns mcr.microsoft.com "*.data.mcr.microsoft.com"
Warning
Pull images from ACR through a private endpoint where you can. If you depend on firewall FQDN rules for ACR data endpoints and a region's endpoint name changes or a geo-replica is added, image pulls fail across the environment at the next scale-out.
- Route table doesn't break inbound. With external ingress and forced tunnelling, return traffic to internet clients must not be sent asymmetrically through the firewall. Internal environments behind Application Gateway or Front Door Private Link avoid this.
- NSG on the subnet, if you add one, keeps the default
AzureLoadBalancerinbound rule and allows traffic within the subnet. Check the documented port list before you add deny rules.
Ingress in front of the environment
- Application Gateway or Front Door uses the app's FQDN as the backend host name (or overrides the host header to it). Envoy in the environment routes by host, so an IP-only backend with no host header returns 404.
- Health probes target an app path that returns 200 without authentication.
- Front Door Premium with Private Link to an internal environment: approve the private endpoint connection on the environment after creating the origin.
Before the first production app
- Image pull from ACR works with a managed identity (
az containerapp registry set --identity), not admin credentials. - One test app has scaled to max replicas, and the subnet still had free IPs (check in IPAM or with
az network vnet subnet showandipConfigurations). - Logs from the system and console tables arrive in Log Analytics.
- DNS resolves from every client location: spoke, hub and on-premises.
- The environment, subnet, zone, records and firewall rules are all in IaC. Rebuilding a fixed setting means a new environment, and you want that to be a pipeline run.
Prevent it next time
- Keep a sizing sheet per environment: profiles, max nodes and subnet prefix. Review it before raising any max.
- Put the platform FQDN allowlist in a shared firewall rule collection group, owned by the platform team, rather than in each app team's rules.
- Alert on revisions whose provisioning state is
Failed. With forced tunnelling, that is usually the first sign a firewall rule is missing.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get