Donfuzius
Donfuzius

Reputation: 21

How to set up Azure App Service multi-container app for CI pipeline

We have implemented a CI/CD pipeline to automatically build and deploy new releases onto a staging slot in our Azure App Service instance. We build and push new container images to our Azure Container Registry tagged with :latest and then trigger the webhook to redeploy the staging slot. Hot-swapping this slot to production also works.

However, if we try out new features on staging which are not ready for production yet, then simply restarting the production slot will automatically load all :latest images. This is less than ideal. Also reverting the hot-swap will not work, as now both slots are on :latest.

Ideally, we would tag our docker images with build numbers, but I don't see a simple way to dynamically update the multi-container configuration (docker-compose.yml) to use these build numbers. Our CI/CD pipeline currently runs on Bitbucket Pipeline, but we could also switch to Azure DevOps if required. Any hints on how to resolve this?

Upvotes: 1

Views: 822

Answers (1)

Donfuzius
Donfuzius

Reputation: 21

Here's what I came up with so far, but ideally there's a simpler approach which does not need Service Principle access from the pipeline:

  • Create a Service Principal on Azure for usage in the pipeline
  • Use BITBUCKET_BUILD_NUMBER to tag the current docker images (see e.g. here)
  • Create a new docker-compose.yml, replacing BITBUCKET_BUILD_NUMBER with e.g. sed
  • Run az webapp config container set --multicontainer-config-file docker-compose.yml -s staging (see here)
  • This should also automatically trigger a reload of the staging slot

Let me know if you can think of a simpler approach.

Upvotes: 1

Related Questions