Deploy a Container to Azure ACI with GitHub Actions

This post will take our GitHub Actions another step forward, and today we will push a stored Docker image from ACR to Azure Container Instances (ACI) using a workflow.

In the previous posts, we learned how to build a Docker image and push it to ACR using GitHub Actions. Also learned how to scan a Docker image with a security vulnerability scan.

Azure Container Instances (ACI)

Azure ACI is a great service that works very well with Azure Container Registry (ACR), and it makes a lot of sense to use the two services in a single workflow, as you will see on the following code.


In the following workflow, I am using the existing code from the previous two posts but adding another step that will take a built Docker image from ACR and push it to ACI.

Go ahead and change the last code block. You will need to provide a resource group name, DNS label and a name. The upside of using that with ACR is that you can use the code block above for the Docker image.

In the code below, we are building, pushing, scanning and deploying a Docker image.

name: Build a Docker image, Push it to ACR and deply to ACI

    branches: [ master ]
    branches: [ master ]


    runs-on: ubuntu-latest
      - uses: actions/[email protected]
      - uses: azure/[email protected]
          username: ${{ secrets.ACR_USERNAME }}
          password: ${{ secrets.ACR_PASSWORD }}

      - run: |
          docker build . -t${{ github.sha }}
          docker push${{ github.sha }}

      - name: Container image scan
        uses: Azure/[email protected]
          image-name:${{ github.sha }}
          username: ${{ secrets.ACR_USERNAME }}
          password: ${{ secrets.ACR_PASSWORD }}
      - name: 'Deploy to Azure Container Instances'
        uses: 'azure/[email protected]'
          resource-group: RG-NAME
          dns-name-label: appdb
          image:${{ github.sha }}
          registry-username: ${{ secrets.ACR_USERNAME }}
          registry-password: ${{ secrets.ACR_PASSWORD }}
          name: appdb-container
          location: 'West US'     

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.