1

right now i work on a pipeline to deploy our microservices to an azure-container-apps environment.

The deployment is done via azure-pipelines, since we use a TFS on prem i need to deploy new versions in a pipeline step with azure cli. For that i use the following command:

az containerapp update 
   --name my-service 
   --resource-group  rg-sample 
   --image sample.azurecr.io/my-service:8440 
   --min-replicas 1 
   --max-replicas 10

This works perfectly new revisions get published and receive all the traffic, and that is exactly the problem im facing.

I know i can activate revisions with the az containerapp revision activate, but the containerapp update command automatically activates the latest revision with a weight of 100%, at least that is what i can see when i review changes with the azure portal.

Im looking for a way to deploy new revisions with azure cli, but with the limitation that the latest revision which was at 100% percent traffic before the deployment, stays there until i say via azure cli switch over to that revision.

Has anyone an idea how to archive that?

Best Erik

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Isparia
  • 682
  • 5
  • 20
  • 1
    I think you would need a separate command for that, like az containerapp ingress traffic, see https://learn.microsoft.com/en-us/cli/azure/containerapp/ingress/traffic?view=azure-cli-latest#az-containerapp-ingress-traffic-set – Jul_DW Nov 08 '22 at 15:28

1 Answers1

1

If your app is in multiple revision mode, you can:

# Make sure your app is in multiple revision mode 
$ az containerapp revision set-mode \
  --name $APP_NAME \
  --resource-group $RESOURCE_GROUP \
  --mode multiple

# Get the current "latestRevision"
$ LATEST_REVISION=$(az containerapp show \
  --name $APP_NAME \
  --resource-group $RESOURCE_GROUP \
  --query properties.latestRevisionName)

# Explicitly set 100% to the latestRevision by name
$ az containerapp ingress traffic set \
  --name $APP_NAME \
  --resource-group $RESOURCE_GROUP \
  --revision-weight $LATEST_REVISION=100

> [
>   {
>     "latestRevision": true, # New revisions will get 0% by default
>     "weight": 0
>   },
>   {
>     "revisionName": "appname--84yjetr",
>     "weight": 100
>   }
> ]
ahmelsayed
  • 7,125
  • 3
  • 28
  • 40
  • Hey thanks for the input, i will take a look tomorrow, but it looks promissing. Still not the easy way i hoped for, but who knows maybe i can twist it in a way it fits ;) – Isparia Nov 14 '22 at 20:48