In this article, you learn how create a zone-redundant container app inside a virtual network. You will create an Azure Container Apps Environment, enable it for zone redundancy, and configure with a new or preexisting virtual network that has an infrastructure subnet.
For more information on how Container Apps supports zone redundancy, see Reliability in Container Apps.
Prerequisites
Zone redundancy is available in all regions that support Container Apps and availability zones.
To see which regions support availability zones, see Azure regions with availability zone support.
To see which regions support Container Apps, see Product Availability by Region.
Create a zone-redundant container app
Use Azure Portal, Azure CLI, or PowerShell to create a zone-redundant container app.
- Go to Azure portal.
- Search for Container Apps in the top search box.
- Select Container Apps.
- Select Create New in the Container Apps Environment field to open the Create Container Apps Environment panel.
- Enter the environment name.
- Select Enabled for the Zone redundancy field.
Zone redundancy requires a virtual network with an infrastructure subnet. You can choose an existing virtual network or create a new one. When creating a new virtual network, you can accept the values provided for you or customize the settings.
- Select the Networking tab.
- To assign a custom virtual network name, select Create New in the Virtual Network field.
- To assign a custom infrastructure subnet name, select Create New in the Infrastructure subnet field.
- You can select Internal or External for the Virtual IP.
- Select Create.
Create a virtual network and infrastructure subnet to include with the Container Apps environment.
When using these commands, replace the <PLACEHOLDERS> with your values.
Note
The Consumption only environment requires a dedicated subnet with a CIDR range of /23 or larger. The workload profiles environment requires a dedicated subnet with a CIDR range of /27 or larger. To learn more about subnet sizing, see the networking architecture overview.
az network vnet create \
--resource-group <RESOURCE_GROUP_NAME> \
--name <VNET_NAME> \
--location <LOCATION> \
--address-prefix 10.0.0.0/16
az network vnet subnet create \
--resource-group <RESOURCE_GROUP_NAME> \
--vnet-name <VNET_NAME> \
--name infrastructure \
--address-prefixes 10.0.0.0/21
Query for the infrastructure subnet ID.
INFRASTRUCTURE_SUBNET=`az network vnet subnet show --resource-group <RESOURCE_GROUP_NAME> --vnet-name <VNET_NAME> --name infrastructure --query "id" -o tsv | tr -d '[:space:]'`
Create the environment with the --zone-redundant parameter. The location must be the same location used when creating the virtual network.
az containerapp env create \
--name <CONTAINER_APP_ENV_NAME> \
--resource-group <RESOURCE_GROUP_NAME> \
--location "<LOCATION>" \
--infrastructure-subnet-resource-id $INFRASTRUCTURE_SUBNET \
--zone-redundant
Create a virtual network and infrastructure subnet to include with the Container Apps environment.
When using these commands, replace the <PLACEHOLDERS> with your values.
Note
The Consumption only environment requires a dedicated subnet with a CIDR range of /23 or larger. The workload profiles environment requires a dedicated subnet with a CIDR range of /27 or larger. To learn more about subnet sizing, see the networking architecture overview.
$SubnetArgs = @{
Name = 'infrastructure-subnet'
AddressPrefix = '10.0.0.0/21'
}
$subnet = New-AzVirtualNetworkSubnetConfig @SubnetArgs
$VnetArgs = @{
Name = <VNetName>
Location = <Location>
ResourceGroupName = <ResourceGroupName>
AddressPrefix = '10.0.0.0/16'
Subnet = $subnet
}
$vnet = New-AzVirtualNetwork @VnetArgs
Query for the infrastructure subnet ID.
$InfrastructureSubnet=(Get-AzVirtualNetworkSubnetConfig -Name $SubnetArgs.Name -VirtualNetwork $vnet).Id
Create the environment with the --zone-redundant parameter. The location must be the same location used when creating the virtual network.
A Log Analytics workspace is required for the Container Apps environment. The following commands create a Log Analytics workspace and save the workspace ID and primary shared key to environment variables.
$WorkspaceArgs = @{
Name = 'myworkspace'
ResourceGroupName = <ResourceGroupName>
Location = <Location>
PublicNetworkAccessForIngestion = 'Enabled'
PublicNetworkAccessForQuery = 'Enabled'
}
New-AzOperationalInsightsWorkspace @WorkspaceArgs
$WorkspaceId = (Get-AzOperationalInsightsWorkspace -ResourceGroupName <ResourceGroupName> -Name $WorkspaceArgs.Name).CustomerId
$WorkspaceSharedKey = (Get-AzOperationalInsightsWorkspaceSharedKey -ResourceGroupName <ResourceGroupName> -Name $WorkspaceArgs.Name).PrimarySharedKey
Create the environment by running the following command:
$EnvArgs = @{
EnvName = <EnvironmentName>
ResourceGroupName = <ResourceGroupName>
Location = <Location>
AppLogConfigurationDestination = "log-analytics"
LogAnalyticConfigurationCustomerId = $WorkspaceId
LogAnalyticConfigurationSharedKey = $WorkspaceSharedKey
VnetConfigurationInfrastructureSubnetId = $InfrastructureSubnet
VnetConfigurationInternal = $true
ZoneRedundant = $true
}
New-AzContainerAppManagedEnv @EnvArgs
Verify zone redundancy
To verify that zone redundancy is enabled for your Container Apps environment:
Go to Azure portal.
Search for Container Apps Environments in the top search box.
Select Container Apps Environments.
Select your environment.
Select JSON View:

Verify that the response contains "zoneRedundant": true:

Run the az container app env show command:
When using this command, replace the <PLACEHOLDERS> with your values.
az containerapp env show \
--name <CONTAINER_APP_ENV_NAME> \
--resource-group <RESOURCE_GROUP_NAME> \
--subscription <SUBSCRIPTION_ID>
The command returns a JSON response. Verify that the response contains "zoneRedundant": true.
Run the az container app env show command:
When using this command, replace the <PLACEHOLDERS> with your values.
$Env = Get-AzContainerAppManagedEnv `
-Name <EnvironmentName> `
-ResourceGroupName <ResourceGroupName>
$Env.ZoneRedundant
The command displays True if the environment is zone-redundant, and False if it isn't.