Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Prepare Azure environments for new workloads—subscriptions, networking, identity, and landing zones
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/services/container-apps/revisions.md
1# Container Apps Revision Management23Revisions are immutable snapshots of a Container App version. Use them for blue/green deployments, canary releases, and instant rollback.45## Revision Modes67| Mode | Behavior | Use Case |8|------|----------|----------|9| `Single` | New revision replaces old immediately | Simple apps, dev/test |10| `Multiple` | Multiple revisions run simultaneously with traffic splitting | Production blue/green, canary |1112## Setting Revision Mode (Bicep)1314```bicep15resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {16name: appName17location: location18properties: {19configuration: {20activeRevisionsMode: 'Multiple'21ingress: {22external: true23targetPort: 808024traffic: [25{ latestRevision: true, weight: 100 }26]27}28}29}30}31```3233> 💡 **Tip:** In Bicep/ARM deployments, you typically can't predictably target a specific new revision name. Use `latestRevision: true` in Bicep for initial deployment, then configure traffic splitting or labels via CLI after the new revision is created.3435> ⚠️ **Warning:** For blue/green workflows, you must first pin traffic to a named revision before deploying a new one. With `latestRevision: true, weight: 100`, new revisions automatically receive all traffic — there is no validation window.3637## Traffic Splitting Patterns3839### Blue/Green Deployment4041Pin traffic to the current revision, deploy a new one, validate, then switch:4243```bash44# Deploy new revision and capture its name from the update output45NEW_REV=$(az containerapp update -n $APP -g $RG --image $NEW_IMAGE \46--query properties.latestRevisionName -o tsv)4748# Test the new revision directly via its revision-specific URL49az containerapp revision list -n $APP -g $RG -o table5051# Switch 100% traffic to the new revision52az containerapp ingress traffic set -n $APP -g $RG \53--revision-weight "$NEW_REV=100"54```5556### Canary Release5758Gradually shift traffic to validate the new revision under load:5960| Phase | Current | Canary | Duration |61|-------|---------|--------|----------|62| 1 | 90% | 10% | 15 min |63| 2 | 50% | 50% | 30 min |64| 3 | 0% | 100% | — |6566```bash67# List revisions to identify current stable and new canary68az containerapp revision list -n $APP -g $RG -o table6970STABLE_REV=<stable-revision-name>71CANARY_REV=<canary-revision-name>7273az containerapp ingress traffic set -n $APP -g $RG \74--revision-weight "$STABLE_REV=90" "$CANARY_REV=10"75```7677### Label-Based Routing7879Use labels instead of revision names for stable references:8081```bash82# Assign labels83az containerapp revision label add -n $APP -g $RG \84--label stable --revision "$APP--v1"85az containerapp revision label add -n $APP -g $RG \86--label canary --revision "$APP--v2"8788# Route by label89az containerapp ingress traffic set -n $APP -g $RG \90--label-weight stable=80 canary=2091```9293> 💡 **Tip:** Label-based routing lets you swap revision targets without changing traffic rules.9495## Rollback9697Revert instantly by redirecting all traffic to a known-good revision (e.g., one labeled `stable`):9899```bash100# List active revisions and identify the known-good one101az containerapp revision list -n $APP -g $RG -o table102103# Roll back using label-based routing (preferred)104az containerapp ingress traffic set -n $APP -g $RG \105--label-weight stable=100106107# Or roll back to a specific revision by name108az containerapp ingress traffic set -n $APP -g $RG \109--revision-weight "<known-good-revision-name>=100"110```111112## Revision Lifecycle113114| Action | Command |115|--------|---------|116| List revisions | `az containerapp revision list -n $APP -g $RG` |117| Show revision details | `az containerapp revision show -n $APP -g $RG --revision $REV` |118| Activate a revision | `az containerapp revision activate -n $APP -g $RG --revision $REV` |119| Deactivate a revision | `az containerapp revision deactivate -n $APP -g $RG --revision $REV` |120| Restart a revision | `az containerapp revision restart -n $APP -g $RG --revision $REV` |121122> ⚠️ **Warning:** Deactivated revisions cannot receive traffic. Reactivate before routing traffic to them.123124## Terraform Traffic Config125126```hcl127resource "azurerm_container_app" "app" {128name = var.app_name129container_app_environment_id = azurerm_container_app_environment.env.id130resource_group_name = azurerm_resource_group.rg.name131revision_mode = "Multiple"132133ingress {134external_enabled = true135target_port = 8080136traffic_weight {137label = "stable"138revision_suffix = "v1"139percentage = 80140}141traffic_weight {142label = "canary"143revision_suffix = "v2"144percentage = 20145}146}147}148```149150## Recommendations151152| Scenario | Revision Mode | Traffic Strategy |153|----------|---------------|------------------|154| Dev/Test | Single | N/A — auto-replace |155| Prod API | Multiple | Blue/green with instant swap |156| High-risk change | Multiple | Canary (10% → 50% → 100%) |157| Feature flags | Multiple | Label-based routing |158