Azure CI/CD 带有 Flask 应用程序的管道无法通过 ZIP 部署进行部署
Azure CI/CD Pipeline with flask app unable to deploy through ZIP deploy
我无法将我的 Flask 应用程序部署到 Azure 门户站点。我的构建通过了,但我的部署在最后一步失败了,试图将项目推送到 Azure 门户网站。我正在使用 Azure 门户在那里部署,但不知道要寻找什么来解决这个问题。我是 CI/CD 版本的新手。我包含了完整的 yaml 构建(没有一些变量)和管道图像。如果有其他信息我需要 post 以获得帮助,请告诉我。
# Project root folder. Point to the folder containing manage.py file.
projectRoot: $(System.DefaultWorkingDirectory)
# Python version: 3.7
pythonVersion: '3.7'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: BuildJob
pool:
vmImage: $(vmImageName)
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(pythonVersion)'
displayName: 'Use Python $(pythonVersion)'
- script: |
python -m venv antenv
source antenv/bin/activate
python -m pip install --upgrade pip
pip install setup
pip install -r requirements.txt
workingDirectory: $(projectRoot)
displayName: "Install requirements"
- script: |
source antenv/bin/activate
python build.py
workingDirectory: $(projectRoot)
displayName: "Download Weights and Models"
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(projectRoot)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
displayName: 'Upload package'
artifact: drop
- stage: Deploy
displayName: 'Deploy Web App'
dependsOn: Build
condition: succeeded()
jobs:
- deployment: DeploymentJob
pool:
vmImage: $(vmImageName)
environment: $(environmentName)
strategy:
runOnce:
deploy:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(pythonVersion)'
displayName: 'Use Python version'
- task: AzureWebApp@1
displayName: 'Deploy Azure Web App : dl-sandbox'
inputs:
azureSubscription: $(azureServiceConnectionId)
appName: $(webAppName)
package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
上述错误可能是由于应用服务的定价层级太小造成的。您可以尝试使用更高定价层重新创建您的应用服务。
创建 Web 应用程序时,选择更改大小 以在 Azure 门户中选择更高的定价层。
如果上述方法无效。您可以检查以下步骤以显示更多错误消息并解决问题。
要对 Azure 应用服务进行故障排除:
Go to Your Web App in Azure> App Service logs >turn on Detailed Error Messages.
要对 Azure 管道进行故障排除:
Set the pipeline variable system.debug=true
. Or check Enable system diagnostics
when run your pipeline, See here for more information.
我无法将我的 Flask 应用程序部署到 Azure 门户站点。我的构建通过了,但我的部署在最后一步失败了,试图将项目推送到 Azure 门户网站。我正在使用 Azure 门户在那里部署,但不知道要寻找什么来解决这个问题。我是 CI/CD 版本的新手。我包含了完整的 yaml 构建(没有一些变量)和管道图像。如果有其他信息我需要 post 以获得帮助,请告诉我。
# Project root folder. Point to the folder containing manage.py file.
projectRoot: $(System.DefaultWorkingDirectory)
# Python version: 3.7
pythonVersion: '3.7'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: BuildJob
pool:
vmImage: $(vmImageName)
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(pythonVersion)'
displayName: 'Use Python $(pythonVersion)'
- script: |
python -m venv antenv
source antenv/bin/activate
python -m pip install --upgrade pip
pip install setup
pip install -r requirements.txt
workingDirectory: $(projectRoot)
displayName: "Install requirements"
- script: |
source antenv/bin/activate
python build.py
workingDirectory: $(projectRoot)
displayName: "Download Weights and Models"
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(projectRoot)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
displayName: 'Upload package'
artifact: drop
- stage: Deploy
displayName: 'Deploy Web App'
dependsOn: Build
condition: succeeded()
jobs:
- deployment: DeploymentJob
pool:
vmImage: $(vmImageName)
environment: $(environmentName)
strategy:
runOnce:
deploy:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(pythonVersion)'
displayName: 'Use Python version'
- task: AzureWebApp@1
displayName: 'Deploy Azure Web App : dl-sandbox'
inputs:
azureSubscription: $(azureServiceConnectionId)
appName: $(webAppName)
package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
上述错误可能是由于应用服务的定价层级太小造成的。您可以尝试使用更高定价层重新创建您的应用服务。
创建 Web 应用程序时,选择更改大小 以在 Azure 门户中选择更高的定价层。
如果上述方法无效。您可以检查以下步骤以显示更多错误消息并解决问题。
要对 Azure 应用服务进行故障排除:
Go to Your Web App in Azure> App Service logs >turn on Detailed Error Messages.
要对 Azure 管道进行故障排除:
Set the pipeline variable
system.debug=true
. Or checkEnable system diagnostics
when run your pipeline, See here for more information.