【发布时间】:2021-02-02 21:57:48
【问题描述】:
我正在尝试使用 Azure Devops 构建一个 Flask 应用程序,我点击了这个链接
https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python-webapp?view=azure-devops
我能够成功构建和部署示例应用程序。
但是当我在 requirements.txt 中添加其他包并将其推送到 Azure 存储库时。 .yaml 文件自动运行,但在构建阶段,所有包都在安装,在管道阶段和部署阶段我没有收到任何错误,但是当我尝试测试应用程序时,它显示包未找到错误。我没有更改 .yaml 文件中的任何内容
# Python to Linux Web App on Azure
# Build your Python project and deploy it to Azure as a Linux Web App.
# Change python version to one thats appropriate for your application.
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
trigger:
- master
variables:
# Azure Resource Manager connection created during pipeline creation
azureServiceConnectionId: '#############'
# Web app name
webAppName: 'flaskappdemo2'
# Agent VM image name
vmImageName: 'ubuntu-latest'
# Environment name
environmentName: 'flaskappdemo2'
# Project root folder. Point to the folder containing manage.py file.
projectRoot: $(System.DefaultWorkingDirectory)
# Python version: 3.6
pythonVersion: '3.6'
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"
- 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 : flaskappdemo2'
inputs:
azureSubscription: $(azureServiceConnectionId)
appName: $(webAppName)
package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
startUpCommand: 'gunicorn --bind=0.0.0.0 --workers=4 startup:app'
这些是日志:
【问题讨论】:
标签: python azure flask azure-devops azure-web-app-service