1+ # Python to Linux Web App on Azure
2+ # Build your Python project and deploy it to Azure as a Linux Web App.
3+ # Change python version to one thats appropriate for your application.
4+ # https://docs.microsoft.com/azure/devops/pipelines/languages/python
5+
6+ trigger :
7+ - main
8+
9+ variables :
10+ # Azure Resource Manager connection created during pipeline creation
11+ azureServiceConnectionId : ' c423dcd5-a239-4cc7-af01-9729ec5c9125'
12+
13+ # Web app name
14+ webAppName : ' python-sample-vscode-flask-tutorial-mv'
15+
16+ # Agent VM image name
17+ vmImageName : ' ubuntu-latest'
18+
19+ # Environment name
20+ environmentName : ' python-sample-vscode-flask-tutorial-mv'
21+
22+ # Project root folder. Point to the folder containing manage.py file.
23+ projectRoot : $(System.DefaultWorkingDirectory)
24+
25+ # Python version: 3.7
26+ pythonVersion : ' 3.7'
27+
28+ stages :
29+ - stage : Build
30+ displayName : Build stage
31+ jobs :
32+ - job : BuildJob
33+ pool :
34+ vmImage : $(vmImageName)
35+ steps :
36+ - task : UsePythonVersion@0
37+ inputs :
38+ versionSpec : ' $(pythonVersion)'
39+ displayName : ' Use Python $(pythonVersion)'
40+
41+ - script : |
42+ python -m venv antenv
43+ source antenv/bin/activate
44+ python -m pip install --upgrade pip
45+ pip install setup
46+ pip install -r requirements.txt
47+ workingDirectory: $(projectRoot)
48+ displayName: "Install requirements"
49+
50+ - task : ArchiveFiles@2
51+ displayName : ' Archive files'
52+ inputs :
53+ rootFolderOrFile : ' $(projectRoot)'
54+ includeRootFolder : false
55+ archiveType : zip
56+ archiveFile : $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
57+ replaceExistingArchive : true
58+
59+ - upload : $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
60+ displayName : ' Upload package'
61+ artifact : drop
62+
63+ - stage : Deploy
64+ displayName : ' Deploy Web App'
65+ dependsOn : Build
66+ condition : succeeded()
67+ jobs :
68+ - deployment : DeploymentJob
69+ pool :
70+ vmImage : $(vmImageName)
71+ environment : $(environmentName)
72+ strategy :
73+ runOnce :
74+ deploy :
75+ steps :
76+
77+ - task : UsePythonVersion@0
78+ inputs :
79+ versionSpec : ' $(pythonVersion)'
80+ displayName : ' Use Python version'
81+
82+ - task : AzureWebApp@1
83+ displayName : ' Deploy Azure Web App : python-sample-vscode-flask-tutorial-mv'
84+ inputs :
85+ azureSubscription : $(azureServiceConnectionId)
86+ appName : $(webAppName)
87+ package : $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
0 commit comments