azureazure-container-apps

(ContainerAppLabelsModeInvalidTraffic) In container apps labels revision mode a traffic weight and label must be provided for each active revision


I have an azure container app that i am running in deployment mode: Deployment labels Automatic activation of multiple revisions using labels.

Here is what I am doing:

#create a second revision for green commitId
az containerapp update --name $APP_NAME \
  --resource-group $RESOURCE_GROUP \
  --image mcr.microsoft.com/k8se/samples/test-app:$GREEN_COMMIT_ID \
  --revision-suffix $GREEN_COMMIT_ID  \
  --set-env-vars REVISION_COMMIT_ID=$GREEN_COMMIT_ID

#give that revision a 'green' label
az containerapp revision label add \
  --name $APP_NAME \
  --resource-group $RESOURCE_GROUP \
  --label green \
  --revision $APP_NAME--$GREEN_COMMIT_ID \
  --yes

as per document https://learn.microsoft.com/en-us/azure/container-apps/blue-green-deployment?pivots=azure-cli but on assigning labels step I get error (ContainerAppLabelsModeInvalidTraffic) In container apps labels revision mode a traffic weight and label must be provided for each active revision.

What am i missing here, documentation does not seem to point out anything else.


Solution

  • The error you're encountering:

    (ContainerAppLabelsModeInvalidTraffic) In container apps labels revision mode a traffic weight and label must be provided for each active revision.

    is due to label-based traffic mode in Azure Container Apps, which requires that:

    Every active revision must have a label, and
    Every label must have an assigned traffic weight.
    

    If a new revision is created but a label or traffic weight is missing, you'll hit this error.

    I reproduced the issue and successfully resolved it using the following CLI-based steps. This approach uses the multiple revisions with automatic activation model and explicitly configures label-based traffic routing.

    I defined variables separately:

    RESOURCE_GROUP=ca-labels-test
    LOCATION=eastus
    ENV_NAME=caenv-test
    APP_NAME=sample-label-app
    BLUE_COMMIT_ID=bluev1
    GREEN_COMMIT_ID=greenv1
    

    RG:

    az group create --name $RESOURCE_GROUP --location $LOCATION
    

    Create container app env:

    az containerapp env create \
      --name $ENV_NAME \
      --resource-group $RESOURCE_GROUP \
      --location $LOCATION
    

    Create your base app and its first revision. The --revisions-mode multiple flag enables support for multiple active revisions like blue-green.

    az containerapp create \
      --name $APP_NAME \
      --resource-group $RESOURCE_GROUP \
      --environment $ENV_NAME \
      --image mcr.microsoft.com/k8se/samples/test-app:latest \
      --revision-suffix $BLUE_COMMIT_ID \
      --ingress external \
      --target-port 80 \
      --env-vars REVISION_COMMIT_ID=$BLUE_COMMIT_ID \
      --revisions-mode multiple
    

    Assign a user-friendly label blue to the specific revision, making it easier to manage and route traffic later.

    az containerapp revision label add \
      --name $APP_NAME \
      --resource-group $RESOURCE_GROUP \
      --label blue \
      --revision $APP_NAME--$BLUE_COMMIT_ID
    

    Explicitly assigns 100% traffic to the blue label. This is important because label-based traffic mode must be activated before creating new revisions.

    az containerapp ingress traffic set \
      --name $APP_NAME \
      --resource-group $RESOURCE_GROUP \
      --label blue=100
    

    Create a second revision. Since traffic is label-controlled, you need to assign a label and traffic weight immediately after.

    az containerapp update \
      --name $APP_NAME \
      --resource-group $RESOURCE_GROUP \
      --image mcr.microsoft.com/k8se/samples/test-app:latest \
      --revision-suffix $GREEN_COMMIT_ID \
      --set-env-vars REVISION_COMMIT_ID=$GREEN_COMMIT_ID
    

    Prevent the error without this, Azure won’t know how to route traffic to this revision, violating label-based mode rules.

    az containerapp revision label add \
      --name $APP_NAME \
      --resource-group $RESOURCE_GROUP \
      --label green \
      --revision $APP_NAME--$GREEN_COMMIT_ID
    

    This is the final required step — ensures both revisions are labeled and have a defined traffic percentage (even 0%).

    az containerapp ingress traffic set \
      --name $APP_NAME \
      --resource-group $RESOURCE_GROUP \
      --label blue=0 \
      --label green=100
    

    Check your app status:

    az containerapp show \
      --name $APP_NAME \
      --resource-group $RESOURCE_GROUP \
      --query properties.configuration.ingress.fqdn \
      --output tsv
    

    You will get URl:

    sample-label-app.proudmoss-a1b2c3d4.eastus.azurecontainerapps.io
    

    enter image description here

    The root issue was that label-based routing requires strict traffic rules per active revision. I validated this workaround in my own test setup, and the steps above successfully resolved the error.

    Feel free to follow them exactly, let me know how it goes.