|
| 1 | +--- |
| 2 | +title: Configuring virtual networks Azure Container Apps environments |
| 3 | +description: Learn how to configure virtual networks in Azure Container Apps. |
| 4 | +services: container-apps |
| 5 | +author: craigshoemaker |
| 6 | +ms.service: azure-container-apps |
| 7 | +ms.topic: conceptual |
| 8 | +ms.date: 05/01/2025 |
| 9 | +ms.author: cshoe |
| 10 | +--- |
| 11 | + |
| 12 | +# Virtual network configuration |
| 13 | + |
| 14 | +A virtual network creates a secure boundary around your Azure Container Apps [environment](environment.md). By default, environments are created with a VNet that is automatically generated. However, using an existing VNet provides more Azure networking features such as integration with Application Gateway, Network Security Groups, and communication with resources behind private endpoints. This configuration is important for enterprise customers who need to isolate internal, mission-critical applications from the public internet. |
| 15 | + |
| 16 | +As you create a virtual network, keep in mind the following situations: |
| 17 | + |
| 18 | +- If you want your container app to restrict all outside access, create an [internal Container Apps environment](networking.md#accessibility-level). |
| 19 | + |
| 20 | +- If you use your own VNet, you need to provide a subnet dedicated exclusively to your container app. This subnet isn't available to other services. |
| 21 | + |
| 22 | +- Network addresses are assigned from a subnet range you define as the environment is created. |
| 23 | + |
| 24 | + - You can define the subnet range used by the Container Apps environment. |
| 25 | + |
| 26 | + - You can restrict inbound requests to the environment exclusively to the VNet by deploying the environment as [internal](vnet-custom.md). |
| 27 | + |
| 28 | +> [!NOTE] |
| 29 | +> When you provide your own virtual network, additional [managed resources](custom-virtual-networks.md#managed-resources) are created. These resources incur costs at their associated rates. |
| 30 | +
|
| 31 | +As you begin to design the network around your container app, refer to [Plan virtual networks](../virtual-network/virtual-network-vnet-plan-design-arm.md). |
| 32 | + |
| 33 | +:::image type="content" source="media/networking/azure-container-apps-virtual-network.png" alt-text="Diagram of how Azure Container Apps environments use an existing V NET, or you can provide your own."::: |
| 34 | + |
| 35 | +> [!NOTE] |
| 36 | +> Moving VNets among different resource groups or subscriptions isn't allowed if the VNet is in use by a Container Apps environment. |
| 37 | +
|
| 38 | +## Subnet |
| 39 | + |
| 40 | +Virtual network integration depends on a dedicated subnet. The allocation of IP addresses in a subnet and the supported subnet sizes depend on the [plan](plans.md) you're using in Azure Container Apps. |
| 41 | + |
| 42 | +Select your subnet size carefully. Subnet sizes can't be modified after you create a Container Apps environment. |
| 43 | + |
| 44 | +Different environment types have different subnet requirements: |
| 45 | + |
| 46 | +# [Workload profiles environment](#tab/workload-profiles-env) |
| 47 | + |
| 48 | +- `/27` is the minimum subnet size required for virtual network integration. |
| 49 | + |
| 50 | +- You must delegate your subnet to `Microsoft.App/environments`. |
| 51 | + |
| 52 | +- When using an external environment with external ingress, inbound traffic routes through the infrastructure’s public IP rather than through your subnet. |
| 53 | + |
| 54 | +- Container Apps automatically reserves 12 IP addresses for integration with the subnet. The number of IP addresses required for infrastructure integration doesn't vary based on the scale demands of the environment. Additional IP addresses are allocated according to the following rules depending on the type of workload profile you're using more IP addresses are allocated depending on your environment's workload profile: |
| 55 | + |
| 56 | + - [Dedicated workload profile](workload-profiles-overview.md#profile-types): As your container app scales out, each node has one IP address assigned. |
| 57 | + |
| 58 | + - [Consumption workload profile](workload-profiles-overview.md#profile-types): Each IP address may be shared among multiple replicas. When planning for how many IP addresses are required for your app, plan for 1 IP address per 10 replicas. |
| 59 | + |
| 60 | +- When you make a [change to a revision](revisions.md#revision-scope-changes) in single revision mode, the required address space is doubled for a short period of time in order to support zero downtime deployments. This affects the real, available supported replicas or nodes for a given subnet size. The following table shows both the maximum available addresses per CIDR block and the effect on horizontal scale. |
| 61 | + |
| 62 | + | Subnet Size | Available IP Addresses<sup>1</sup> | Max nodes (Dedicated workload profile)<sup>2</sup>| Max replicas (Consumption workload profile)<sup>2</sup> | |
| 63 | + |--|--|--|--| |
| 64 | + | /23 | 498 | 249 | 2,490 | |
| 65 | + | /24 | 242 | 121 | 1,210 | |
| 66 | + | /25 | 114 | 57 | 570 | |
| 67 | + | /26 | 50 | 25 | 250 | |
| 68 | + | /27 | 18 | 9 | 90 | |
| 69 | + |
| 70 | + <sup>1</sup> The available IP addresses is the size of the subnet minus the 14 IP addresses required for Azure Container Apps infrastructure which includes 5 IP addresses reserved by the subnet. |
| 71 | + <sup>2</sup> This is accounting for apps in single revision mode. |
| 72 | + |
| 73 | +# [Consumption-only environment](#tab/consumption-only-env) |
| 74 | + |
| 75 | +- `/23` is the minimum subnet size required for virtual network integration. |
| 76 | + |
| 77 | +- Your subnet must not be delegated to any services. |
| 78 | + |
| 79 | +- The Container Apps runtime reserves a minimum of 60 IPs for infrastructure in your VNet. The reserved amount may increase up to 256 addresses as apps in your environment scale. |
| 80 | + |
| 81 | +- As your apps scale, a new IP address is allocated for each new replica. |
| 82 | + |
| 83 | +- When you make a [change to a revision](revisions.md#revision-scope-changes) in single revision mode, the required address space is doubled for a short period of time in order to support zero downtime deployments. This affects the real, available supported replicas for a given subnet size. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +### Subnet address range restrictions |
| 88 | + |
| 89 | +# [Workload profiles environment](#tab/workload-profiles-env) |
| 90 | + |
| 91 | +Subnet address ranges can't overlap with the following ranges reserved by Azure Kubernetes Services: |
| 92 | + |
| 93 | +- 169.254.0.0/16 |
| 94 | +- 172.30.0.0/16 |
| 95 | +- 172.31.0.0/16 |
| 96 | +- 192.0.2.0/24 |
| 97 | + |
| 98 | +In addition, a workload profiles environment reserves the following addresses: |
| 99 | + |
| 100 | +- 100.100.0.0/17 |
| 101 | +- 100.100.128.0/19 |
| 102 | +- 100.100.160.0/19 |
| 103 | +- 100.100.192.0/19 |
| 104 | + |
| 105 | +# [Consumption-only environment](#tab/consumption-only-env) |
| 106 | + |
| 107 | +Subnet address ranges can't overlap with the following ranges reserved by Azure Kubernetes Services: |
| 108 | + |
| 109 | +- 169.254.0.0/16 |
| 110 | +- 172.30.0.0/16 |
| 111 | +- 172.31.0.0/16 |
| 112 | +- 192.0.2.0/24 |
| 113 | + |
| 114 | +If you created your container apps environment with a custom service CIDR, make sure your container app's subnet (or any peered subnet) doesn't conflict with your custom service CIDR range. |
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | +### Subnet configuration with CLI |
| 119 | + |
| 120 | +As a Container Apps environment is created, you provide resource IDs for a single subnet. |
| 121 | + |
| 122 | +If you're using the CLI, the parameter to define the subnet resource ID is `infrastructure-subnet-resource-id`. The subnet hosts infrastructure components and user app containers. |
| 123 | + |
| 124 | +If you're using the Azure CLI with a Consumption only environment and the [platformReservedCidr](vnet-custom-internal.md#networking-parameters) range is defined, both subnets must not overlap with the IP range defined in `platformReservedCidr`. |
| 125 | + |
| 126 | +## NAT gateway integration |
| 127 | + |
| 128 | +You can use NAT Gateway to simplify outbound connectivity for your outbound internet traffic in your virtual network in a workload profiles environment. |
| 129 | + |
| 130 | +When you configure a NAT Gateway on your subnet, the NAT Gateway provides a static public IP address for your environment. All outbound traffic from your container app is routed through the NAT Gateway's static public IP address. |
| 131 | + |
| 132 | +## Managed resources |
| 133 | + |
| 134 | +When you deploy an internal or an external environment into your own network, a new resource group is created in the Azure subscription where your environment is hosted. This resource group contains infrastructure components managed by the Azure Container Apps platform. Don't modify the services in this group or the resource group itself. |
| 135 | + |
| 136 | +> [!NOTE] |
| 137 | +> User-defined tags assigned to your Container Apps environment are replicated to all resources within the resource group, including the resource group itself. |
| 138 | +
|
| 139 | +# [Workload profiles environment](#tab/workload-profiles-env) |
| 140 | + |
| 141 | +The name of the resource group created in the Azure subscription where your environment is hosted is prefixed with `ME_` by default, and the resource group name *can* be customized as you create your container app environment. |
| 142 | + |
| 143 | +For external environments, the resource group contains a public IP address used specifically for inbound connectivity to your external environment and a load balancer. For internal environments, the resource group only contains a [Load Balancer](https://azure.microsoft.com/pricing/details/load-balancer/). |
| 144 | + |
| 145 | +In addition to the standard [Azure Container Apps billing](./billing.md), you're billed for: |
| 146 | + |
| 147 | +- One standard static [public IP](https://azure.microsoft.com/pricing/details/ip-addresses/) for egress if using an internal or external environment, plus one standard static [public IP](https://azure.microsoft.com/pricing/details/ip-addresses/) for ingress if using an external environment. If you need more public IPs for egress due to SNAT issues, [open a support ticket to request an override](https://azure.microsoft.com/support/create-ticket/). |
| 148 | + |
| 149 | +- One standard [load balancer](https://azure.microsoft.com/pricing/details/load-balancer/). |
| 150 | + |
| 151 | +- The cost of data processed (in GBs) includes both ingress and egress for management operations. |
| 152 | + |
| 153 | +# [Consumption only environment](#tab/consumption-only-env) |
| 154 | + |
| 155 | +The name of the resource group created in the Azure subscription where your environment is hosted is prefixed with `MC_` by default, and the resource group name *can't* be customized when you create a container app. The resource group contains public IP addresses used specifically for outbound connectivity from your environment and a load balancer. |
| 156 | + |
| 157 | +In addition to the standard [Azure Container Apps billing](./billing.md), you're billed for: |
| 158 | + |
| 159 | +- One standard static [public IP](https://azure.microsoft.com/pricing/details/ip-addresses/) for egress. If you need more IPs for egress due to Source Network Address Translation (SNAT) issues, [open a support ticket to request an override](https://azure.microsoft.com/support/create-ticket/). |
| 160 | + |
| 161 | +- Two standard [load balancers](https://azure.microsoft.com/pricing/details/load-balancer/) if using an internal environment, or one standard [load balancer](https://azure.microsoft.com/pricing/details/load-balancer/) if using an external environment. Each load balancer has fewer than six rules. The cost of data processed (in GBs) includes both ingress and egress for management operations. |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +## Next steps |
| 166 | + |
| 167 | +> [!div class="nextstepaction"] |
| 168 | +> [Managing outbound connections with Azure Firewall](use-azure-firewall.md) |
0 commit comments