Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#175126219] Healthcheck step in pipeline #117

Merged
merged 4 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ parameters:
- name: 'PRODUCTION_DEPLOY_TYPE'
displayName: 'Method to achieve deployment in Production (if enabled):'
type: string
default: deployToStagingSlot
default: deployToStagingSlotAndSwap
values:
- deployToStagingSlot
- deployToProductionSlot
Expand All @@ -90,6 +90,14 @@ trigger:
pool:
vmImage: 'windows-2019'

resources:
repositories:
- repository: pagopaCommons
type: github
name: pagopa/azure-pipeline-templates
ref: refs/tags/v1
endpoint: 'pagopa'

stages:
# A) Build and code validation
- stage: Build
Expand Down Expand Up @@ -200,6 +208,10 @@ stages:
azureSubscription: '$(TEST_AZURE_SUBSCRIPTION)'
resourceGroupName: '$(TEST_RESOURCE_GROUP_NAME)'
appName: '$(TEST_APP_NAME)'
healthcheckEndpoint: 'https://$(TEST_APP_NAME).staging.azurewebsites.net/info'
gunzip marked this conversation as resolved.
Show resolved Hide resolved
containerInstanceResourceGroup: 'io-p-rg-common'
containerInstanceVNet: 'io-p-vnet-common'
containerInstanceSubnet: 'azure-devops'


# D) Deploy to PRODUCTION environment if one of the following conditions apply:
Expand Down Expand Up @@ -233,3 +245,7 @@ stages:
azureSubscription: '$(PRODUCTION_AZURE_SUBSCRIPTION)'
resourceGroupName: '$(PRODUCTION_RESOURCE_GROUP_NAME)'
appName: '$(PRODUCTION_APP_NAME)'
healthcheckEndpoint: 'https://$(PRODUCTION_APP_NAME).staging.azurewebsites.net/info'
gunzip marked this conversation as resolved.
Show resolved Hide resolved
containerInstanceResourceGroup: 'io-p-rg-common'
containerInstanceVNet: 'io-p-vnet-common'
containerInstanceSubnet: 'azure-devops'
34 changes: 31 additions & 3 deletions azure-templates/deploy-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ parameters:
- name: 'appName'
type: string
default: ''

# full endpoint to perform healthcheck against,
- name: 'healthcheckEndpoint'
type: string

# the resource group must be the same where vnet is created
- name: 'containerInstanceResourceGroup'
type: string

# attached vnet to the container instance
- name: 'containerInstanceVNet'
type: string

# container instance subnet
- name: 'containerInstanceSubnet'
type: string

steps:
- template: ./make-build-steps.yml
Expand Down Expand Up @@ -87,7 +103,8 @@ steps:

# Option 3: deployment with two slots ('staging' and 'production')
- ${{ if eq(parameters.deployType, 'deployToStagingSlotAndSwap') }}:
- task: AzureFunctionApp@1 # First step: deploy to 'staging' slot
# First step: deploy to 'staging' slot
- task: AzureFunctionApp@1
inputs:
azureSubscription: '${{ parameters.azureSubscription }}'
resourceGroupName: '${{ parameters.resourceGroupName }}'
Expand All @@ -98,8 +115,19 @@ steps:
deployToSlotOrASE: true
slotName: 'staging'
displayName: Deploy to staging slot

- task: AzureAppServiceManage@0 # Second step: swap 'staging' with 'production' slot

# Second step: check the app is working
- template: templates/rest-healthcheck/template.yaml@pagopaCommons
parameters:
azureSubscription: '${{ parameters.azureSubscription }}'
appName: '${{ parameters.appName }}'
endpoint: '${{ parameters.healthcheckEndpoint }}'
containerInstanceResourceGroup: '${{ parameters.containerInstanceResourceGroup }}'
containerInstanceVNet: '${{ parameters.containerInstanceVNet }}'
containerInstanceSubnet: '${{ parameters.containerInstanceSubnet }}'

# Third step: swap 'staging' with 'production' slot
- task: AzureAppServiceManage@0
inputs:
azureSubscription: '${{ parameters.azureSubscription }}'
resourceGroupName: '${{ parameters.resourceGroupName }}'
Expand Down