django 错误:无法将Web包部署到App Service,错误:部署失败,使用ZIP Deploy部署包失败,有关详细信息,请参阅日志

lstz6jyr  于 2023-10-21  发布在  Go
关注(0)|答案(1)|浏览(146)

Deployment Failed. deployer = GITHUB_ZIP_DEPLOY deploymentPath = ZipDeploy. Extract zip. Remote build. Error: Failed to deploy web package to App Service. Error: Deployment Failed, Package deployment using ZIP Deploy failed. Refer logs for more details.
我正在使用GitHub部署我的Django应用程序到Azure应用程序服务它一直工作正常,直到GitHub开始使用zip部署或包部署,然后它给了我这个错误。
我尝试在我的应用配置中添加WEBSITE_RUN_FROM_PACKAGE=1,部署在GitHub中没有错误,但应用根本不工作。

31moq8wy

31moq8wy1#

  • 检查Azure App Service=>Deployment Center=>Logs中的日志以详细了解错误。
  • 尝试在App Service=>Configuration=>New Application Settings(in old Azure portal) (or) App Service=>Environmental variables中添加设置 SCM_DO_BUILD_DURING_DEPLOYMENT=1ENABLE_ORYX_BUILD=1
  • 如果问题仍然存在,请尝试使用其他方法(如GitHub Actions)进行部署。

我使用 *GitHub Actions * 将一个 * 简单的Django Web应用程序 * 部署到 Azure App Service

执行步骤:

  • 通过Enabling continuous deployment在 *Azure门户 * 中创建 * 应用服务 * 期间配置 * 部署 *,并选择GitHub repository and branch of your Django project

  • 它创建工作流,在 GitHub 中自动将项目部署到Azure,部署状态可以在your repository=>Actions中跟踪。
    我的工作流(.yml):
name: Build and deploy Python app to Azure Web App - <web_app_name>

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up Python version
        uses: actions/setup-python@v1
        with:
          python-version: '3.10'

      - name: Create and start virtual environment
        run: |
          python -m venv venv
          source venv/bin/activate
      
      - name: Install dependencies
        run: pip install -r requirements.txt
        
      # Optional: Add step to run tests here (PyTest, Django test suites, etc.)
      
      - name: Upload artifact for deployment jobs
        uses: actions/upload-artifact@v2
        with:
          name: python-app
          path: |
            . 
            !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@v2
        with:
          name: python-app
          path: .
          
      - name: 'Deploy to Azure Web App'
        uses: azure/webapps-deploy@v2
        id: deploy-to-webapp
        with:
          app-name: '<web_app_name>'
          slot-name: 'Production'
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_87XXXXXX }}

部署成功:

回复:

相关问题