diff --git a/azure-pipelines-1.yml b/azure-pipelines-1.yml new file mode 100644 index 000000000..d8c7e91af --- /dev/null +++ b/azure-pipelines-1.yml @@ -0,0 +1,87 @@ +# 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: '1abd5883-a777-46c7-a866-6beae1857989' + + # Web app name + webAppName: 'sampletestapp2481' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + + # Environment name + environmentName: 'sampletestapp2481' + + # Project root folder. Point to the folder containing manage.py file. + projectRoot: $(System.DefaultWorkingDirectory) + + # Python version: 3.5 + pythonVersion: '3.5' + +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)/Application$(Build.BuildId).zip + replaceExistingArchive: true + + - upload: $(Build.ArtifactStagingDirectory)/Application$(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 : {{ webAppName }}' + inputs: + azureSubscription: $(azureServiceConnectionId) + appName: $(webAppName) + package: $(Pipeline.Workspace)/drop/*$(Build.BuildId).zip \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..f2e6a0db6 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,88 @@ +# 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: '59b9d486-f32e-4633-b56f-be0cb3eda8e0' + + # Web app name + webAppName: 'Devops-python-test' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + + # Environment name + environmentName: 'Devops-python-test' + + # 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)/Application$(Build.BuildId).zip + replaceExistingArchive: true + + + - task: PublishBuildArtifacts@1 + displayName: 'Publish 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 : Devops-python-test' + inputs: + azureSubscription: $(azureServiceConnectionId) + appName: $(webAppName) + package: '$(System.DefaultWorkingDirectory)\**\Application*.zip' + startUpCommand: 'gunicorn --bind=0.0.0.0 --workers=4 startup:app' \ No newline at end of file diff --git a/hello_app/templates/about.html b/hello_app/templates/about.html index 8611b6414..4042e7fd6 100644 --- a/hello_app/templates/about.html +++ b/hello_app/templates/about.html @@ -3,5 +3,5 @@ About us {% endblock %} {% block content %} -
About page for the Visual Studio Code Flask tutorial.
+welcome to About page for the Visual Studio Code Flask tutorial.
{% endblock %} diff --git a/hello_app/templates/home.html b/hello_app/templates/home.html index 95609fecd..b7922ffd4 100644 --- a/hello_app/templates/home.html +++ b/hello_app/templates/home.html @@ -3,5 +3,5 @@ Home {% endblock %} {% block content %} -Home page for the Visual Studio Code Flask tutorial.
+the Visual Studio Code Flask tutorial.
{% endblock %}