forked from microsoft/presidio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Image Redactor to CI pipeline (microsoft#530)
* add image-redactor to pr pipeline
- Loading branch information
Showing
4 changed files
with
209 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,130 +1,169 @@ | ||
# Blue Green deployment to app service for container of presidio services. | ||
# The template uses a deployment and runs smoke test on health endpoint | ||
# before switching the slots. | ||
parameters: | ||
ENVIRONMNT_NAME: | ||
REGISTRY_NAME: | ||
AZURE_SUBSCRIPTION: | ||
ANALYZER_APP_NAME: | ||
ANONYMIZER_APP_NAME: | ||
RESOURCE_GROUP_NAME: | ||
TAG: | ||
jobs: | ||
- job: DeployAnalyzer | ||
displayName: Deploy Analyzer to ${{ parameters.ENVIRONMNT_NAME }} Environment | ||
pool: | ||
vmImage: 'ubuntu-16.04' | ||
steps: | ||
- checkout: none | ||
- task: AzureCLI@2 | ||
displayName: Create staging slot | ||
name: createStagingSlot | ||
inputs: | ||
azureSubscription: ${{ parameters.AZURE_SUBSCRIPTION }} | ||
scriptType: bash | ||
scriptLocation: inlineScript | ||
inlineScript: | | ||
set -eux # fail on error | ||
az webapp deployment slot create --name ${{ parameters.ANALYZER_APP_NAME }} --resource-group ${{ parameters.RESOURCE_GROUP_NAME }} --configuration-source ${{ parameters.ANALYZER_APP_NAME }} --slot staging | ||
URI=https://$(az webapp config hostname list --webapp-name ${{ parameters.ANALYZER_APP_NAME }} --resource-group ${{ parameters.RESOURCE_GROUP_NAME }} --slot staging --query '[0].name' -o tsv) | ||
echo $URI | ||
echo "##vso[task.setvariable variable=STAGING_URI;isOutput=true]$URI" | ||
- task: AzureWebAppContainer@1 | ||
displayName: Deploy to staging slot | ||
inputs: | ||
azureSubscription: ${{ parameters.AZURE_SUBSCRIPTION }} | ||
deployToSlotOrASE: true | ||
resourceGroupName: ${{ parameters.RESOURCE_GROUP_NAME }} | ||
appName: ${{ parameters.ANALYZER_APP_NAME }} | ||
slotName: staging | ||
imageName: ${{ parameters.REGISTRY_NAME }}presidio-analyzer:${{ parameters.TAG }} | ||
|
||
- job: DeployAnonymizer | ||
displayName: Deploy Anonymizer to ${{ parameters.ENVIRONMNT_NAME }} Environment | ||
pool: | ||
vmImage: 'ubuntu-16.04' | ||
steps: | ||
- checkout: none | ||
- task: AzureCLI@2 | ||
displayName: Create staging slot | ||
name: createStagingSlot | ||
inputs: | ||
azureSubscription: ${{ parameters.AZURE_SUBSCRIPTION }} | ||
scriptType: bash | ||
scriptLocation: inlineScript | ||
inlineScript: | | ||
set -eux # fail on error | ||
az webapp deployment slot create --name ${{ parameters.ANONYMIZER_APP_NAME }} --resource-group ${{ parameters.RESOURCE_GROUP_NAME }} --configuration-source ${{ parameters.ANONYMIZER_APP_NAME }} --slot staging | ||
URI=https://$(az webapp config hostname list --webapp-name ${{ parameters.ANONYMIZER_APP_NAME }} --resource-group ${{ parameters.RESOURCE_GROUP_NAME }} --slot staging --query '[0].name' -o tsv) | ||
echo $URI | ||
echo "##vso[task.setvariable variable=STAGING_URI;isOutput=true]$URI" | ||
- task: AzureWebAppContainer@1 | ||
displayName: Deploy to staging slot | ||
inputs: | ||
azureSubscription: ${{ parameters.AZURE_SUBSCRIPTION }} | ||
deployToSlotOrASE: true | ||
resourceGroupName: ${{ parameters.RESOURCE_GROUP_NAME }} | ||
appName: ${{ parameters.ANONYMIZER_APP_NAME }} | ||
slotName: staging | ||
imageName: ${{ parameters.REGISTRY_NAME }}presidio-anonymizer:${{ parameters.TAG }} | ||
|
||
- job: TestDeployment | ||
displayName: Smoke and E2E Tests on the deployement | ||
dependsOn: | ||
- DeployAnalyzer | ||
- DeployAnonymizer | ||
variables: | ||
ANALYZER_STAGING_URI: $[ dependencies.DeployAnalyzer.outputs['createStagingSlot.STAGING_URI'] ] | ||
ANONYMIZER_STAGING_URI: $[ dependencies.DeployAnonymizer.outputs['createStagingSlot.STAGING_URI'] ] | ||
steps: | ||
- task: Bash@3 | ||
displayName: 'Wait and Smoke test' | ||
timeoutInMinutes: 10 | ||
inputs: | ||
targetType: 'inline' | ||
script: | | ||
set -ux # do not fail on error | ||
ANALYZER_STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 1 --max-time 10 $ANALYZER_STAGING_URI/health) | ||
ANONYMIZER_STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 1 --max-time 10 $ANONYMIZER_STAGING_URI/health) | ||
echo analyzer status code is $ANALYZER_STATUS_CODE | ||
echo anonymizer status code is $ANONYMIZER_STATUS_CODE | ||
while [ ! $ANALYZER_STATUS_CODE == 200 ] || [ ! $ANONYMIZER_STATUS_CODE == 200 ] | ||
do | ||
sleep 30 | ||
ANALYZER_STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 1 --max-time 10 $ANALYZER_STAGING_URI/health) | ||
ANONYMIZER_STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 1 --max-time 10 $ANONYMIZER_STAGING_URI/health) | ||
echo analyzer status code is $ANALYZER_STATUS_CODE | ||
echo anonymizer status code is $ANONYMIZER_STATUS_CODE | ||
done | ||
- template: ./e2e-tests.yml | ||
parameters: | ||
test_suite: 'integration' | ||
analyzer_base_url: $(ANALYZER_STAGING_URI) | ||
anonymizer_base_url: $(ANONYMIZER_STAGING_URI) | ||
|
||
- job: SwapBothSlots | ||
condition: eq(dependencies.TestDeployment.result, 'Succeeded') | ||
strategy: | ||
matrix: | ||
Analyzer: | ||
Name: 'Analyzer' | ||
AppServiceName: ${{ parameters.ANALYZER_APP_NAME }} | ||
Anonymizer: | ||
Name: 'Anonymizer' | ||
AppServiceName: ${{ parameters.ANONYMIZER_APP_NAME }} | ||
displayName: Swap slots from staging to production | ||
dependsOn: TestDeployment | ||
steps: | ||
- checkout: none | ||
- task: AzureAppServiceManage@0 | ||
displayName: Swap $(Name) slot | ||
inputs: | ||
azureSubscription: ${{ parameters.AZURE_SUBSCRIPTION }} | ||
action: Swap Slots | ||
webAppName: $(AppServiceName) | ||
sourceSlot: staging | ||
resourceGroupName: ${{ parameters.RESOURCE_GROUP_NAME }} | ||
# Blue Green deployment to app service for container of presidio services. | ||
# The template uses a deployment and runs smoke test on health endpoint | ||
# before switching the slots. | ||
parameters: | ||
ENVIRONMNT_NAME: | ||
REGISTRY_NAME: | ||
AZURE_SUBSCRIPTION: | ||
ANALYZER_APP_NAME: | ||
ANONYMIZER_APP_NAME: | ||
IMAGE_REDACTOR_APP_NAME: | ||
RESOURCE_GROUP_NAME: | ||
TAG: | ||
jobs: | ||
- job: DeployAnalyzer | ||
displayName: Deploy Analyzer to ${{ parameters.ENVIRONMNT_NAME }} Environment | ||
pool: | ||
vmImage: 'ubuntu-16.04' | ||
steps: | ||
- checkout: none | ||
- task: AzureCLI@2 | ||
displayName: Create staging slot | ||
name: createStagingSlot | ||
inputs: | ||
azureSubscription: ${{ parameters.AZURE_SUBSCRIPTION }} | ||
scriptType: bash | ||
scriptLocation: inlineScript | ||
inlineScript: | | ||
set -eux # fail on error | ||
az webapp deployment slot create --name ${{ parameters.ANALYZER_APP_NAME }} --resource-group ${{ parameters.RESOURCE_GROUP_NAME }} --configuration-source ${{ parameters.ANALYZER_APP_NAME }} --slot staging | ||
URI=https://$(az webapp config hostname list --webapp-name ${{ parameters.ANALYZER_APP_NAME }} --resource-group ${{ parameters.RESOURCE_GROUP_NAME }} --slot staging --query '[0].name' -o tsv) | ||
echo $URI | ||
echo "##vso[task.setvariable variable=STAGING_URI;isOutput=true]$URI" | ||
- task: AzureWebAppContainer@1 | ||
displayName: Deploy to staging slot | ||
inputs: | ||
azureSubscription: ${{ parameters.AZURE_SUBSCRIPTION }} | ||
deployToSlotOrASE: true | ||
resourceGroupName: ${{ parameters.RESOURCE_GROUP_NAME }} | ||
appName: ${{ parameters.ANALYZER_APP_NAME }} | ||
slotName: staging | ||
imageName: ${{ parameters.REGISTRY_NAME }}presidio-analyzer:${{ parameters.TAG }} | ||
|
||
- job: DeployAnonymizer | ||
displayName: Deploy Anonymizer to ${{ parameters.ENVIRONMNT_NAME }} Environment | ||
pool: | ||
vmImage: 'ubuntu-16.04' | ||
steps: | ||
- checkout: none | ||
- task: AzureCLI@2 | ||
displayName: Create staging slot | ||
name: createStagingSlot | ||
inputs: | ||
azureSubscription: ${{ parameters.AZURE_SUBSCRIPTION }} | ||
scriptType: bash | ||
scriptLocation: inlineScript | ||
inlineScript: | | ||
set -eux # fail on error | ||
az webapp deployment slot create --name ${{ parameters.ANONYMIZER_APP_NAME }} --resource-group ${{ parameters.RESOURCE_GROUP_NAME }} --configuration-source ${{ parameters.ANONYMIZER_APP_NAME }} --slot staging | ||
URI=https://$(az webapp config hostname list --webapp-name ${{ parameters.ANONYMIZER_APP_NAME }} --resource-group ${{ parameters.RESOURCE_GROUP_NAME }} --slot staging --query '[0].name' -o tsv) | ||
echo $URI | ||
echo "##vso[task.setvariable variable=STAGING_URI;isOutput=true]$URI" | ||
- task: AzureWebAppContainer@1 | ||
displayName: Deploy to staging slot | ||
inputs: | ||
azureSubscription: ${{ parameters.AZURE_SUBSCRIPTION }} | ||
deployToSlotOrASE: true | ||
resourceGroupName: ${{ parameters.RESOURCE_GROUP_NAME }} | ||
appName: ${{ parameters.ANONYMIZER_APP_NAME }} | ||
slotName: staging | ||
imageName: ${{ parameters.REGISTRY_NAME }}presidio-anonymizer:${{ parameters.TAG }} | ||
|
||
- job: DeployImageRedactor | ||
displayName: Deploy Image Redactor to ${{ parameters.ENVIRONMNT_NAME }} Environment | ||
pool: | ||
vmImage: 'ubuntu-16.04' | ||
steps: | ||
- checkout: none | ||
- task: AzureCLI@2 | ||
displayName: Create staging slot | ||
name: createStagingSlot | ||
inputs: | ||
azureSubscription: ${{ parameters.AZURE_SUBSCRIPTION }} | ||
scriptType: bash | ||
scriptLocation: inlineScript | ||
inlineScript: | | ||
set -eux # fail on error | ||
az webapp deployment slot create --name ${{ parameters.IMAGE_REDACTOR_APP_NAME }} --resource-group ${{ parameters.RESOURCE_GROUP_NAME }} --configuration-source ${{ parameters.IMAGE_REDACTOR_APP_NAME }} --slot staging | ||
URI=https://$(az webapp config hostname list --webapp-name ${{ parameters.IMAGE_REDACTOR_APP_NAME }} --resource-group ${{ parameters.RESOURCE_GROUP_NAME }} --slot staging --query '[0].name' -o tsv) | ||
echo $URI | ||
echo "##vso[task.setvariable variable=STAGING_URI;isOutput=true]$URI" | ||
- task: AzureWebAppContainer@1 | ||
displayName: Deploy to staging slot | ||
inputs: | ||
azureSubscription: ${{ parameters.AZURE_SUBSCRIPTION }} | ||
deployToSlotOrASE: true | ||
resourceGroupName: ${{ parameters.RESOURCE_GROUP_NAME }} | ||
appName: ${{ parameters.IMAGE_REDACTOR_APP_NAME }} | ||
slotName: staging | ||
imageName: ${{ parameters.REGISTRY_NAME }}presidio-image-redactor:${{ parameters.TAG }} | ||
|
||
- job: TestDeployment | ||
displayName: Smoke and E2E Tests on the deployement | ||
dependsOn: | ||
- DeployAnalyzer | ||
- DeployAnonymizer | ||
- DeployImageRedactor | ||
variables: | ||
ANALYZER_STAGING_URI: $[ dependencies.DeployAnalyzer.outputs['createStagingSlot.STAGING_URI'] ] | ||
ANONYMIZER_STAGING_URI: $[ dependencies.DeployAnonymizer.outputs['createStagingSlot.STAGING_URI'] ] | ||
IMAGE_REDACTOR_STAGING_URI: $[ dependencies.DeployImageRedactor.outputs['createStagingSlot.STAGING_URI'] ] | ||
steps: | ||
- task: Bash@3 | ||
displayName: 'Wait and Smoke test' | ||
timeoutInMinutes: 10 | ||
inputs: | ||
targetType: 'inline' | ||
script: | | ||
set -ux # do not fail on error | ||
ANALYZER_STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 1 --max-time 10 $ANALYZER_STAGING_URI/health) | ||
ANONYMIZER_STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 1 --max-time 10 $ANONYMIZER_STAGING_URI/health) | ||
IMAGE_REDACTOR_STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 1 --max-time 10 $IMAGE_REDACTOR_STAGING_URI/health) | ||
echo analyzer status code is $ANALYZER_STATUS_CODE | ||
echo anonymizer status code is $ANONYMIZER_STATUS_CODE | ||
echo image redactor status code is $IMAGE_REDACTOR_STATUS_CODE | ||
while [ ! $ANALYZER_STATUS_CODE == 200 ] || [ ! $ANONYMIZER_STATUS_CODE == 200 ] || [ ! $IMAGE_REDACTOR_STATUS_CODE == 200 ] | ||
do | ||
sleep 30 | ||
ANALYZER_STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 1 --max-time 10 $ANALYZER_STAGING_URI/health) | ||
ANONYMIZER_STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 1 --max-time 10 $ANONYMIZER_STAGING_URI/health) | ||
IMAGE_REDACTOR_STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 1 --max-time 10 $IMAGE_REDACTOR_STAGING_URI/health) | ||
echo analyzer status code is $ANALYZER_STATUS_CODE | ||
echo anonymizer status code is $ANONYMIZER_STATUS_CODE | ||
echo image redactor status code is $IMAGE_REDACTOR_STATUS_CODE | ||
done | ||
- template: ./e2e-tests.yml | ||
parameters: | ||
test_suite: 'integration' | ||
analyzer_base_url: $(ANALYZER_STAGING_URI) | ||
anonymizer_base_url: $(ANONYMIZER_STAGING_URI) | ||
|
||
- job: SwapBothSlots | ||
condition: eq(dependencies.TestDeployment.result, 'Succeeded') | ||
strategy: | ||
matrix: | ||
Analyzer: | ||
Name: 'Analyzer' | ||
AppServiceName: ${{ parameters.ANALYZER_APP_NAME }} | ||
Anonymizer: | ||
Name: 'Anonymizer' | ||
AppServiceName: ${{ parameters.ANONYMIZER_APP_NAME }} | ||
ImageRedactor: | ||
Name: 'ImageRedactor' | ||
AppServiceName: ${{ parameters.IMAGE_REDACTOR_APP_NAME }} | ||
displayName: Swap slots from staging to production | ||
dependsOn: TestDeployment | ||
steps: | ||
- checkout: none | ||
- task: AzureAppServiceManage@0 | ||
displayName: Swap $(Name) slot | ||
inputs: | ||
azureSubscription: ${{ parameters.AZURE_SUBSCRIPTION }} | ||
action: Swap Slots | ||
webAppName: $(AppServiceName) | ||
sourceSlot: staging | ||
resourceGroupName: ${{ parameters.RESOURCE_GROUP_NAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.