|
| 1 | +--- |
| 2 | +title: Reliability in Azure Container Apps |
| 3 | +description: Learn how to ensure application reliability in Azure Container Apps |
| 4 | +services: container-apps |
| 5 | +author: craigshoemaker |
| 6 | +ms.author: cshoe |
| 7 | +ms.service: container-apps |
| 8 | +ms.custom: subject-reliability, references_regions |
| 9 | +ms.topic: reliability-article |
| 10 | +ms.date: 08/29/2023 |
| 11 | +--- |
| 12 | + |
| 13 | +# Reliability in Azure Container Apps |
| 14 | + |
| 15 | +This article describes reliability support in Azure Container Apps, and covers both regional resiliency with availability zones and cross-region resiliency with disaster recovery. For a more detailed overview of reliability in Azure, see [Azure reliability](/azure/well-architected/resiliency/). |
| 16 | + |
| 17 | +## Availability zone support |
| 18 | + |
| 19 | +[!INCLUDE [next step](includes/reliability-availability-zone-description-include.md)] |
| 20 | + |
| 21 | +Azure Container Apps uses [availability zones](availability-zones-overview.md#availability-zones) in regions where they're available to provide high-availability protection for your applications and data from data center failures. |
| 22 | + |
| 23 | +By enabling Container Apps' zone redundancy feature, replicas are automatically distributed across the zones in the region. Traffic is load balanced among the replicas. If a zone outage occurs, traffic is automatically routed to the replicas in the remaining zones. |
| 24 | + |
| 25 | +> [!NOTE] |
| 26 | +> There is no extra charge for enabling zone redundancy, but it only provides benefits when you have 2 or more replicas, with 3 or more being ideal since most regions that support zone redundancy have 3 zones. |
| 27 | +
|
| 28 | +### Prerequisites |
| 29 | + |
| 30 | +Azure Container Apps offers the same reliability support regardless of your plan type. |
| 31 | + |
| 32 | +Azure Container Apps uses [availability zones](availability-zones-overview.md#availability-zones) in regions where they're available. For a list of regions that support availability zones, see [Availability zone service and regional support](availability-zones-service-support.md). |
| 33 | + |
| 34 | +### SLA improvements |
| 35 | + |
| 36 | +There are no increased SLAs for Azure Container Apps. For more information on the Azure Container Apps SLAs, see [Service Level Agreement for Azure Container Apps](https://azure.microsoft.com/support/legal/sla/container-apps/). |
| 37 | + |
| 38 | +### Create a resource with availability zone enabled |
| 39 | + |
| 40 | +#### Set up zone redundancy in your Container Apps environment |
| 41 | + |
| 42 | +To take advantage of availability zones, you must enable zone redundancy when you create a Container Apps environment. The environment must include a virtual network with an available subnet. To ensure proper distribution of replicas, set your app's minimum replica count to three. |
| 43 | + |
| 44 | +##### Enable zone redundancy via the Azure portal |
| 45 | + |
| 46 | +To create a container app in an environment with zone redundancy enabled using the Azure portal: |
| 47 | + |
| 48 | +1. Navigate to the Azure portal. |
| 49 | +1. Search for **Container Apps** in the top search box. |
| 50 | +1. Select **Container Apps**. |
| 51 | +1. Select **Create New** in the *Container Apps Environment* field to open the *Create Container Apps Environment* panel. |
| 52 | +1. Enter the environment name. |
| 53 | +1. Select **Enabled** for the *Zone redundancy* field. |
| 54 | + |
| 55 | +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. |
| 56 | + |
| 57 | +1. Select the **Networking** tab. |
| 58 | +1. To assign a custom virtual network name, select **Create New** in the *Virtual Network* field. |
| 59 | +1. To assign a custom infrastructure subnet name, select **Create New** in the *Infrastructure subnet* field. |
| 60 | +1. You can select **Internal** or **External** for the *Virtual IP*. |
| 61 | +1. Select **Create**. |
| 62 | + |
| 63 | +:::image type="content" source="../container-apps/media/screen-shot-vnet-configuration.png" alt-text="Screenshot of Networking tab in Create Container Apps Environment page."::: |
| 64 | + |
| 65 | +##### Enable zone redundancy with the Azure CLI |
| 66 | + |
| 67 | +Create a virtual network and infrastructure subnet to include with the Container Apps environment. |
| 68 | + |
| 69 | +When using these commands, replace the `<PLACEHOLDERS>` with your values. |
| 70 | + |
| 71 | +>[!NOTE] |
| 72 | +> 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](../container-apps/networking.md#subnet). |
| 73 | +
|
| 74 | +# [Azure CLI](#tab/azure-cli) |
| 75 | + |
| 76 | +```azurecli-interactive |
| 77 | +az network vnet create \ |
| 78 | + --resource-group <RESOURCE_GROUP_NAME> \ |
| 79 | + --name <VNET_NAME> \ |
| 80 | + --location <LOCATION> \ |
| 81 | + --address-prefix 10.0.0.0/16 |
| 82 | +``` |
| 83 | + |
| 84 | +```azurecli-interactive |
| 85 | +az network vnet subnet create \ |
| 86 | + --resource-group <RESOURCE_GROUP_NAME> \ |
| 87 | + --vnet-name <VNET_NAME> \ |
| 88 | + --name infrastructure \ |
| 89 | + --address-prefixes 10.0.0.0/21 |
| 90 | +``` |
| 91 | + |
| 92 | +# [Azure PowerShell](#tab/azure-powershell) |
| 93 | + |
| 94 | +```azurepowershell-interactive |
| 95 | +$SubnetArgs = @{ |
| 96 | + Name = 'infrastructure-subnet' |
| 97 | + AddressPrefix = '10.0.0.0/21' |
| 98 | +} |
| 99 | +$subnet = New-AzVirtualNetworkSubnetConfig @SubnetArgs |
| 100 | +``` |
| 101 | + |
| 102 | +```azurepowershell-interactive |
| 103 | +$VnetArgs = @{ |
| 104 | + Name = <VNetName> |
| 105 | + Location = <Location> |
| 106 | + ResourceGroupName = <ResourceGroupName> |
| 107 | + AddressPrefix = '10.0.0.0/16' |
| 108 | + Subnet = $subnet |
| 109 | +} |
| 110 | +$vnet = New-AzVirtualNetwork @VnetArgs |
| 111 | +``` |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +Next, query for the infrastructure subnet ID. |
| 116 | + |
| 117 | +# [Azure CLI](#tab/azure-cli) |
| 118 | + |
| 119 | +```azurecli-interactive |
| 120 | +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:]'` |
| 121 | +``` |
| 122 | + |
| 123 | +# [Azure PowerShell](#tab/azure-powershell) |
| 124 | + |
| 125 | +```azurepowershell-interactive |
| 126 | +$InfrastructureSubnet=(Get-AzVirtualNetworkSubnetConfig -Name $SubnetArgs.Name -VirtualNetwork $vnet).Id |
| 127 | +``` |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +Finally, create the environment with the `--zone-redundant` parameter. The location must be the same location used when creating the virtual network. |
| 132 | + |
| 133 | +# [Azure CLI](#tab/azure-cli) |
| 134 | + |
| 135 | +```azurecli-interactive |
| 136 | +az containerapp env create \ |
| 137 | + --name <CONTAINER_APP_ENV_NAME> \ |
| 138 | + --resource-group <RESOURCE_GROUP_NAME> \ |
| 139 | + --location "<LOCATION>" \ |
| 140 | + --infrastructure-subnet-resource-id $INFRASTRUCTURE_SUBNET \ |
| 141 | + --zone-redundant |
| 142 | +``` |
| 143 | + |
| 144 | +# [Azure PowerShell](#tab/azure-powershell) |
| 145 | + |
| 146 | +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. |
| 147 | + |
| 148 | +```azurepowershell-interactive |
| 149 | +$WorkspaceArgs = @{ |
| 150 | + Name = 'myworkspace' |
| 151 | + ResourceGroupName = <ResourceGroupName> |
| 152 | + Location = <Location> |
| 153 | + PublicNetworkAccessForIngestion = 'Enabled' |
| 154 | + PublicNetworkAccessForQuery = 'Enabled' |
| 155 | +} |
| 156 | +New-AzOperationalInsightsWorkspace @WorkspaceArgs |
| 157 | +$WorkspaceId = (Get-AzOperationalInsightsWorkspace -ResourceGroupName <ResourceGroupName> -Name $WorkspaceArgs.Name).CustomerId |
| 158 | +$WorkspaceSharedKey = (Get-AzOperationalInsightsWorkspaceSharedKey -ResourceGroupName <ResourceGroupName> -Name $WorkspaceArgs.Name).PrimarySharedKey |
| 159 | +``` |
| 160 | + |
| 161 | +To create the environment, run the following command: |
| 162 | + |
| 163 | +```azurepowershell-interactive |
| 164 | +$EnvArgs = @{ |
| 165 | + EnvName = <EnvironmentName> |
| 166 | + ResourceGroupName = <ResourceGroupName> |
| 167 | + Location = <Location> |
| 168 | + AppLogConfigurationDestination = "log-analytics" |
| 169 | + LogAnalyticConfigurationCustomerId = $WorkspaceId |
| 170 | + LogAnalyticConfigurationSharedKey = $WorkspaceSharedKey |
| 171 | + VnetConfigurationInfrastructureSubnetId = $InfrastructureSubnet |
| 172 | + VnetConfigurationInternal = $true |
| 173 | +} |
| 174 | +New-AzContainerAppManagedEnv @EnvArgs |
| 175 | +``` |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | +### Safe deployment techniques |
| 180 | + |
| 181 | +When you set up [zone redundancy in your container app](#set-up-zone-redundancy-in-your-container-apps-environment), replicas are distributed automatically across the zones in the region. After the replicas are distributed, traffic is load balanced among them. If a zone outage occurs, traffic automatically routes to the replicas in the remaining zone. |
| 182 | + |
| 183 | +You should still use safe deployment techniques such as [blue-green deployment](../container-apps/blue-green-deployment.md). Azure Container Apps doesn't provide one-zone-at-a-time deployment or upgrades. |
| 184 | + |
| 185 | +If you have enabled [session affinity](../container-apps/sticky-sessions.md), and a zone goes down, clients for that zone are routed to new replicas because the previous replicas are no longer available. Any state associated with the previous replicas is lost. |
| 186 | + |
| 187 | +### Availability zone redeployment and migration |
| 188 | + |
| 189 | +To take advantage of availability zones, enable zone redundancy as you create the Container Apps environment. The environment must include a virtual network with an available subnet. You can't migrate an existing Container Apps environment from nonavailability zone support to availability zone support. |
| 190 | + |
| 191 | +## Disaster recovery: cross-region failover |
| 192 | + |
| 193 | +In the unlikely event of a full region outage, you have the option of using one of two strategies: |
| 194 | + |
| 195 | +- **Manual recovery**: Manually deploy to a new region, or wait for the region to recover, and then manually redeploy all environments and apps. |
| 196 | + |
| 197 | +- **Resilient recovery**: First, deploy your container apps in advance to multiple regions. Next, use Azure Front Door or Azure Traffic Manager to handle incoming requests, pointing traffic to your primary region. Then, should an outage occur, you can redirect traffic away from the affected region. For more information, see [Cross-region replication in Azure](cross-region-replication-azure.md). |
| 198 | + |
| 199 | +> [!NOTE] |
| 200 | +> Regardless of which strategy you choose, make sure your deployment configuration files are in source control so you can easily redeploy if necessary. |
| 201 | +
|
| 202 | +## More guidance |
| 203 | + |
| 204 | +The following resources can help you create your own disaster recovery plan: |
| 205 | + |
| 206 | +- [Failure and disaster recovery for Azure applications](/azure/architecture/reliability/disaster-recovery) |
| 207 | +- [Azure resiliency technical guidance](/azure/architecture/checklist/resiliency-per-service) |
| 208 | + |
| 209 | +## Next steps |
| 210 | + |
| 211 | +> [!div class="nextstepaction"] |
| 212 | +> [Reliability in Azure](availability-zones-overview.md) |
0 commit comments