最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin13浏览0评论

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:

  • Tried redeploying: The deployment always references the non-existent slot.

  • GitHub Actions Workflow: I’m using the following configuration to deploy to Azure:

    - name: Deploy to Azure Web App
      uses: azure/webapps-deploy@v3
      with:
        app-name: 'my-fastapi-webapp'
        slot-name: 'Production'
    
  • Removed slot reference from the workflow, but the issue persists.

My questions:

  • How can I fix the "Resource Not Found" error? Is there a way to ensure the deployment targets the production slot or a valid deployment slot?
  • Do I need to remove the slot-name reference from the workflow, or should I create the missing slot manually?

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:

  • Tried redeploying: The deployment always references the non-existent slot.

  • GitHub Actions Workflow: I’m using the following configuration to deploy to Azure:

    - name: Deploy to Azure Web App
      uses: azure/webapps-deploy@v3
      with:
        app-name: 'my-fastapi-webapp'
        slot-name: 'Production'
    
  • Removed slot reference from the workflow, but the issue persists.

My questions:

  • How can I fix the "Resource Not Found" error? Is there a way to ensure the deployment targets the production slot or a valid deployment slot?
  • Do I need to remove the slot-name reference from the workflow, or should I create the missing slot manually?
Share Improve this question edited Nov 16, 2024 at 10:48 Azeem 14.8k4 gold badges34 silver badges51 bronze badges asked Nov 16, 2024 at 9:38 Jeeva JoslinJeeva Joslin 296 bronze badges 9
  • 1 please share your .yml file or github repo if possible – Sirra Sneha Commented Nov 16, 2024 at 11:39
  • name: Deploy to Azure Web App uses: azure/webapps-deploy@v3 with: app-name: 'my-fastapi-webapp' slot-name: 'Production' – Jeeva Joslin Commented Nov 16, 2024 at 12:12
  • 1 please add gunicorn --worker-class uvicorn.workers.UvicornWorker --timeout 600 --access-logfile '-' --error-logfile '-' main:app this startup command in configuration section of your azure web app – Sirra Sneha Commented Nov 16, 2024 at 13:35
  • 1 try adding this apt-get update && apt-get install -y libmagic1 && gunicorn --worker-class uvicorn.workers.UvicornWorker --timeout 600 --access-logfile '-' --error-logfile '-' main:app it worked for me. – Sirra Sneha Commented Nov 16, 2024 at 15:51
  • 1 Let us continue this discussion in chat. – Sirra Sneha Commented Nov 16, 2024 at 15:58
 |  Show 4 more comments

1 Answer 1

Reset to default 2

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

  • The apt-get update command gives the list of available packages, and apt-get install -y libmagic1 installs the libmagic1 library, which is required by python-magic to function properly.

  • Navigate to Configuration section of your Azure Web app - > add the startup command and hit save.

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

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.

Output after deployment:

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论