Azure WebApp with multi-container and using Docker-Compose setup runs successfully on dev machine but Errors on Azure

I am learning about azure and github ci/cd with simple docker-compose setup which is running perfectly on my dev machine but is constantly failing on Azure WebApp with below Errors:

2024-09-04T16:12:01.352714815Z The command could not be loaded, possibly because:
2024-09-04T16:12:01.352738315Z * You intended to execute a .NET application:
2024-09-04T16:12:01.352775915Z The application 'foo.dll' does not exist.
2024-09-04T16:12:01.352781015Z * You intended to execute a .NET SDK command:
2024-09-04T16:12:01.352784615Z No .NET SDKs were found.
2024-09-04T16:12:01.352787915Z
2024-09-04T16:12:01.352790915Z Download a .NET SDK:
2024-09-04T16:12:01.352794015Z https://aka.ms/dotnet/download
2024-09-04T16:12:01.352797215Z
2024-09-04T16:12:01.352800215Z Learn about SDK resolution:
2024-09-04T16:12:01.352806415Z https://aka.ms/dotnet/sdk-not-found

On further checking logs in Deployment Center/Container Logs, I observed that WebApp internally doesn’t even call docker-compose up to start the containers which works perfectly fine on my dev machine but instead runs below commands:

2024-09-04T16:20:41.519Z INFO - Starting multi-container app..
2024-09-04T16:20:42.049Z INFO - Pulling image: bar.azurecr.io/web:latest
2024-09-04T16:20:42.218Z INFO - latest Pulling from web
2024-09-04T16:20:42.265Z INFO - Digest: sha256:<redacted>
2024-09-04T16:20:42.265Z INFO - Status: Image is up to date for bar.azurecr.io/web:latest
2024-09-04T16:20:42.279Z INFO - Pull Image successful, Time taken: 0 Seconds
2024-09-04T16:20:42.339Z INFO - Starting container for site
2024-09-04T16:20:42.340Z INFO - docker run -d -p 6733:5104 --name foo_web-app_0_871e06a6 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=true -e WEBSITE_SITE_NAME=foo -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=foo.azurewebsites.net -e WEBSITE_INSTANCE_ID=<some_id> bar.azurecr.io/web:latest
2024-09-04T16:20:42.341Z INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2024-09-04T16:20:42.887Z INFO - Pulling image: bar.azurecr.io/db:latest
2024-09-04T16:20:43.082Z INFO - latest Pulling from db
2024-09-04T16:20:43.141Z INFO - Digest: sha256:<redacted>
2024-09-04T16:20:43.142Z INFO - Status: Image is up to date for bar.azurecr.io/db:latest
2024-09-04T16:20:43.154Z INFO - Pull Image successful, Time taken: 0 Seconds
2024-09-04T16:20:43.212Z INFO - Starting container for site
2024-09-04T16:20:43.213Z INFO - docker run -d --expose=1433 --name foo_db_0_871e06a6 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=true -e WEBSITE_SITE_NAME=foo -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=foo.azurewebsites.net -e WEBSITE_INSTANCE_ID=<some_id> bar.azurecr.io/db:latest
2024-09-04T16:20:43.214Z INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.

My sample Docker-Compose file

name: sample-app
services:
    web-app:
        image: bar.azurecr.io/web:latest
        environment:
            - ConnectionStrings__DefaultConnection=Server=db;Database=${DbName};User Id=${UserName};Password=${Password};MultipleActiveResultSets=true; TrustServerCertificate=true
        ports:
            - "80:5104"
        volumes:
            - ${WEBAPP_STORAGE_HOME}/app_data:/app
        networks:
            - isolated_network
        depends_on:
            - db    
    db:
        image: bar.azurecr.io/db:latest
        ports:
        - "1433:1433"
        networks:
            - isolated_network
        volumes:
            - ${WEBAPP_STORAGE_HOME}/db_data:/var/opt/mssql
networks:
    isolated_network:
        driver: bridge

My GitHub Workflow file:

name: Build and deploy ASP.Net Core app to an Azure Web App

env:
  ACR_NAME: bar
  AZURE_WEBAPP_NAME: foo    
  AZURE_WEBAPP_PACKAGE_PATH: '.'      
  
on:
  push:
    branches: [ "main" ]
  workflow_dispatch:

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v1
    
    - name: Log in to Azure
      uses: azure/login@v1
      with:
        creds: ${{ secrets.AZURE_CREDENTIALS }}

    - name: Log in to Azure Container Registry
      run: |
        az acr login -n ${{ env.ACR_NAME }}
        
    - name: Build and push Web image
      uses: docker/build-push-action@v2
      with:
        context: .
        push: true
        tags: ${{ env.ACR_NAME }}.azurecr.io/web:latest

    - name: Build and push Db image
      uses: docker/build-push-action@v2
      with:
        context: .
        file: ./DockerDbfile
        push: true
        tags: ${{ env.ACR_NAME }}.azurecr.io/db:latest

    - name: Deploy to Azure Web App
      id: deploy-to-webapp
      uses: azure/webapps-deploy@v2
      with:
        app-name: ${{ env.AZURE_WEBAPP_NAME }}
        configuration-file: 'docker-compose.yml'

My questions are:

  1. Considering that I am using github workflows to build the image, push it to acr and then running docker-compose on webapp all hosted in same subscription, is there a better way to do this?
  2. Any idea on how to troubleshoot the current setup further as this is a very simple use case with .net MVC Core application as web and sqlserver as db all running on docker.
  3. Why did the WebApp not run docker-compose up in container logs 🙂

I created a sample multi container application with docker compose and deployed to the ACR via GitHub.

  • I’ve referred this doc and created the application.

  • Thanks @alaintd for clear explanation I’ve referred this doc to build and push the docker image to Azure Container registry using GitHub actions.

  • Make sure you add your Azure container registry credentials in GitHub repository settings -> secrets and variables ->actions -> New repository secret.

  • I’ve added the below lines of code to my workflow file to login to Azure container registry.

 name: Azure Container Registry Login
        uses: Azure/docker-login@v1
        with:
          login-server: multiappregis.azurecr.io
          username: ${{ secrets.ACR_USERNAME }}
          password: ${{ secrets.ACR_PASSWORD }}

My complete workflow file :

name: Build and Push Docker Images
on:
  push:
    branches:
      - main
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
      - name: Azure Container Registry Login
        uses: Azure/docker-login@v1
        with:
          login-server: multiappregis.azurecr.io
          username: ${{ secrets.ACR_USERNAME }}
          password: ${{ secrets.ACR_PASSWORD }}
      - name: Build and push the first image (app)
        uses: docker/build-push-action@v2
        with:
          context: ./multiapp 
          file: ./multiapp/Dockerfile 
          push: true
          tags: <ACR-NAME>.azurecr.io/app:latest
      - name: Build and push the second image (db)
        uses: docker/build-push-action@v2
        with:
          context: ./multiapp 
          file: ./multiapp/Dockerdb/Dockerfile 
          push: true
          tags: <ACR-NAME>.azurecr.io/db:latest
  • After successfully deploying the images to Azure Container Registry via GitHub Actions.
  • I further deployed the application to Azure App Service using Azure Container Registry

Output:

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật