From 689ca63f0a1e1f057ce1324d7df7c9936b72774d Mon Sep 17 00:00:00 2001 From: marshmallo Date: Mon, 14 Sep 2020 12:28:46 +0530 Subject: [PATCH 01/10] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 89 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..67473b547 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,89 @@ +# 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: '868a2af8-02fa-4cbd-a551-0d02aafeb33e' + + # Web app name + webAppName: 'demo-pipeline' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + + # Environment name + environmentName: 'demo-pipeline' + + # 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" + + - 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 : demo-pipeline' + inputs: + azureSubscription: $(azureServiceConnectionId) + appName: $(webAppName) + appType: webAppLinux + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip + StartupCommand: 'startup.txt' \ No newline at end of file From 7ddb79c2dda12f3cfd164f68f570ea09fca443c4 Mon Sep 17 00:00:00 2001 From: marshmallo Date: Mon, 14 Sep 2020 12:34:24 +0530 Subject: [PATCH 02/10] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 67473b547..73dfc62f0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,8 +22,8 @@ variables: # Project root folder. Point to the folder containing manage.py file. projectRoot: $(System.DefaultWorkingDirectory) - # Python version: 3.7 - pythonVersion: '3.7' + # Python version: 3.6 + pythonVersion: '3.6' stages: - stage: Build From d150c8e503e4fac536e0361d5fd9a4fe5c2c6965 Mon Sep 17 00:00:00 2001 From: marshmallo Date: Mon, 14 Sep 2020 12:44:52 +0530 Subject: [PATCH 03/10] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 73dfc62f0..60af104a2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -39,6 +39,8 @@ stages: displayName: 'Use Python $(pythonVersion)' - script: | + pwd + ls -la python -m venv antenv source antenv/bin/activate python -m pip install --upgrade pip From 95fa9c46c86fadfdf49db2fda957802585021a41 Mon Sep 17 00:00:00 2001 From: marshmallo Date: Mon, 14 Sep 2020 14:56:15 +0530 Subject: [PATCH 04/10] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 60af104a2..c5adeccbd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,7 +17,7 @@ variables: vmImageName: 'ubuntu-latest' # Environment name - environmentName: 'demo-pipeline' + environmentName: 'demo-pipeline-staging' # Project root folder. Point to the folder containing manage.py file. projectRoot: $(System.DefaultWorkingDirectory) From b2da313f16d008ede34d78adfc5d581ec24351f9 Mon Sep 17 00:00:00 2001 From: marshmallo Date: Mon, 14 Sep 2020 15:09:59 +0530 Subject: [PATCH 05/10] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c5adeccbd..948fa719c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,7 +11,7 @@ variables: azureServiceConnectionId: '868a2af8-02fa-4cbd-a551-0d02aafeb33e' # Web app name - webAppName: 'demo-pipeline' + webAppName: 'demo-pipeline/staging' # Agent VM image name vmImageName: 'ubuntu-latest' From 5c2d3f644aaad7c9ea0eb1e80c6a461cb412612d Mon Sep 17 00:00:00 2001 From: marshmallo Date: Mon, 14 Sep 2020 15:22:14 +0530 Subject: [PATCH 06/10] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 948fa719c..c375255c7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,7 +11,7 @@ variables: azureServiceConnectionId: '868a2af8-02fa-4cbd-a551-0d02aafeb33e' # Web app name - webAppName: 'demo-pipeline/staging' + webAppName: 'demo-pipeline' # Agent VM image name vmImageName: 'ubuntu-latest' @@ -87,5 +87,6 @@ stages: azureSubscription: $(azureServiceConnectionId) appName: $(webAppName) appType: webAppLinux + slotName: demo-pipeline-staging package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip StartupCommand: 'startup.txt' \ No newline at end of file From 55ee97c3017a46e706d7abb6d382194d79114bda Mon Sep 17 00:00:00 2001 From: marshmallo Date: Mon, 14 Sep 2020 15:35:13 +0530 Subject: [PATCH 07/10] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c375255c7..57d2ca093 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,6 +9,9 @@ trigger: variables: # Azure Resource Manager connection created during pipeline creation azureServiceConnectionId: '868a2af8-02fa-4cbd-a551-0d02aafeb33e' + + # Resource Group name + resourceGroup: 'Devops-Learning' # Web app name webAppName: 'demo-pipeline' @@ -87,6 +90,8 @@ stages: azureSubscription: $(azureServiceConnectionId) appName: $(webAppName) appType: webAppLinux + deployToSlotOrASE: true + resourceGroupName: $(resourceGroup) slotName: demo-pipeline-staging package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip StartupCommand: 'startup.txt' \ No newline at end of file From 017a59c72c7ca7bc054e8ccaf3c72a5c98e3dafc Mon Sep 17 00:00:00 2001 From: marshmallo Date: Mon, 14 Sep 2020 15:41:50 +0530 Subject: [PATCH 08/10] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 57d2ca093..1285e497a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -92,6 +92,6 @@ stages: appType: webAppLinux deployToSlotOrASE: true resourceGroupName: $(resourceGroup) - slotName: demo-pipeline-staging + slotName: staging package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip StartupCommand: 'startup.txt' \ No newline at end of file From 974e7941a0a586ba21421af3375d66c971921ea3 Mon Sep 17 00:00:00 2001 From: marshmallo Date: Mon, 14 Sep 2020 15:45:58 +0530 Subject: [PATCH 09/10] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1285e497a..9c483c9e6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,7 +11,7 @@ variables: azureServiceConnectionId: '868a2af8-02fa-4cbd-a551-0d02aafeb33e' # Resource Group name - resourceGroup: 'Devops-Learning' + # resourceGroup: 'Devops-Learning' # Web app name webAppName: 'demo-pipeline' @@ -90,8 +90,8 @@ stages: azureSubscription: $(azureServiceConnectionId) appName: $(webAppName) appType: webAppLinux - deployToSlotOrASE: true - resourceGroupName: $(resourceGroup) + # deployToSlotOrASE: true + # resourceGroupName: $(resourceGroup) slotName: staging package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip StartupCommand: 'startup.txt' \ No newline at end of file From e25f6f7ad925d9b675bf87d34685837927894164 Mon Sep 17 00:00:00 2001 From: marshmallo Date: Mon, 14 Sep 2020 15:51:38 +0530 Subject: [PATCH 10/10] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9c483c9e6..7eebfd3af 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,9 +9,6 @@ trigger: variables: # Azure Resource Manager connection created during pipeline creation azureServiceConnectionId: '868a2af8-02fa-4cbd-a551-0d02aafeb33e' - - # Resource Group name - # resourceGroup: 'Devops-Learning' # Web app name webAppName: 'demo-pipeline' @@ -90,8 +87,6 @@ stages: azureSubscription: $(azureServiceConnectionId) appName: $(webAppName) appType: webAppLinux - # deployToSlotOrASE: true - # resourceGroupName: $(resourceGroup) slotName: staging package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip StartupCommand: 'startup.txt' \ No newline at end of file