azuregithubgithub-actionsfastapi

Azure App Service Deployment Error: "Resource Not Found" for Deployment Slot even if resource exists


I'm trying to deploy a FastAPI application (as Web app) to Azure App Service using GitHub Actions. The deployment seems to be successful, but when I try to access the app, I get the message:

Status Code: 404
Status Message: The Resource 'Microsoft.Web/sites/my-fastapi-webapp/slots/e6dnb2bkfndyfpdx' under resource group 'my-fastapi-rg' was not found.

I am not using any slots.

Steps I’ve taken so far:

My questions:


Solution

  • ERROR - Container tdocs_0_40751cc1 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.

    The error you're encountering occurs because of the incorrect startup command.

    I got the same error after using the startup command that you provided.

    I changed the startup command to below one because

    apt-get update && apt-get install -y libmagic1 && gunicorn --worker-class uvicorn.workers.UvicornWorker --timeout 600 --access-logfile '-' --error-logfile '-' main:app
    

    enter image description here

    This is my workflow file:

    name: Build and deploy Python app to Azure Web App - fastapitestsample18
    
    on:
      push:
        branches:
          - main
      workflow_dispatch:
    
    jobs:
      build:
        runs-on: ubuntu-latest
    
        steps:
          - uses: actions/checkout@v4
    
          - name: Set up Python version
            uses: actions/setup-python@v1
            with:
              python-version: '3.12'
    
          - name: Create and start virtual environment
            run: |
              python -m venv venv
              source venv/bin/activate
    
          - name: Install dependencies
            run: pip install -r requirements.txt
            
          - name: Zip artifact for deployment
            run: zip release.zip ./* -r
    
          - name: Upload artifact for deployment jobs
            uses: actions/upload-artifact@v3
            with:
              name: python-app
              path: |
                release.zip
                !venv/
    
      deploy:
        runs-on: ubuntu-latest
        needs: build
        environment:
          name: 'Production'
          url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
    
        steps:
          - name: Download artifact from build job
            uses: actions/download-artifact@v3
            with:
              name: python-app
    
          - name: Unzip artifact for deployment
            run: unzip release.zip
    
          - name: 'Deploy to Azure Web App'
            uses: azure/webapps-deploy@v2
            id: deploy-to-webapp
            with:
              app-name: 'fastapitestsample18'
              slot-name: 'Production'
              publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_6BE585852CEC4BCEB75B1EBBC05169D3 }}
    

    Successfully deployed the application via GitHub actions.

    enter image description here

    Output after deployment:

    enter image description here

    enter image description here

    enter image description here