Skip to content

Instantly share code, notes, and snippets.

@cporteou
Created January 11, 2021 14:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cporteou/722fc51c3672cbaec3d807822c8d7f6a to your computer and use it in GitHub Desktop.
Save cporteou/722fc51c3672cbaec3d807822c8d7f6a to your computer and use it in GitHub Desktop.
Azure pipelines YAML file containing a test and prod deploy step and using environments for blog article: CI/CD for Azure Data Factory: Adding a production deployment stage
# CICD Pipeline for Azure Data Factory
# Author: Craig Porteous (@cporteous)
trigger:
- adf_publish
pool:
vmImage: 'vs2017-win2016'
stages:
- stage: QAtesting
jobs:
- deployment: Testdeploy
displayName: Test environment deployment
environment: 'Test'
strategy:
runOnce:
deploy:
steps:
- checkout: self
- checkout: 'git://CICD with Azure Data Factory/cpo-configs@refs/heads/main'
- task: AzurePowerShell@5
displayName: 'Stop ADF triggers'
inputs:
azureSubscription: 'Visual Studio Enterprise()'
ScriptType: 'FilePath'
ScriptPath: '$(System.DefaultWorkingDirectory)/cpo-configs/adf-maintenance.ps1'
ScriptArguments: -armTemplate "$(System.DefaultWorkingDirectory)/cpo-datafactory/cpo-adf-dev/ARMTemplateForFactory.json"
-ResourceGroupName "ModernDataPlatform"
-DataFactoryName "cpo-adf-uat"
-predeployment $true
-deleteDeployment $false
azurePowerShellVersion: 'LatestVersion'
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'ARM Template deployment'
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'Visual Studio Enterprise()'
subscriptionId: ''
action: 'Create Or Update Resource Group'
resourceGroupName: 'ModernDataPlatform'
location: 'UK South'
templateLocation: 'Linked artifact'
csmFile: '$(System.DefaultWorkingDirectory)/cpo-datafactory/cpo-adf-dev/ARMTemplateForFactory.json'
csmParametersFile: '$(System.DefaultWorkingDirectory)/cpo-datafactory/cpo-adf-dev/ARMTemplateParametersForFactory.json'
overrideParameters: -factoryName "cpo-adf-uat"
-cpo_kv_properties_typeProperties_baseUrl ""
-cpodatalake_properties_typeProperties_url ""
-cposqlsource_properties_typeProperties_connectionString_secretName ""
deploymentMode: 'Incremental'
- task: AzurePowerShell@5
displayName: 'Clean resources and start ADF triggers'
inputs:
azureSubscription: 'Visual Studio Enterprise()'
ScriptType: 'FilePath'
ScriptPath: '$(System.DefaultWorkingDirectory)/cpo-configs/adf-maintenance.ps1'
ScriptArguments: -armTemplate "$(System.DefaultWorkingDirectory)/cpo-datafactory/cpo-adf-dev/ARMTemplateForFactory.json"
-ResourceGroupName "ModernDataPlatform"
-DataFactoryName "cpo-adf-dev"
-predeployment $false
-deleteDeployment $true
azurePowerShellVersion: 'LatestVersion'
- stage: Production
jobs:
- deployment: Proddeploy
displayName: Production environment deployment
environment: 'Production'
strategy:
runOnce:
deploy:
steps:
- checkout: self
- checkout: 'git://CICD with Azure Data Factory/cpo-configs@refs/heads/main'
- task: AzurePowerShell@5
displayName: 'Stop ADF triggers'
inputs:
azureSubscription: 'Visual Studio Enterprise()'
ScriptType: 'FilePath'
ScriptPath: '$(System.DefaultWorkingDirectory)/cpo-configs/adf-maintenance.ps1'
ScriptArguments: -armTemplate "$(System.DefaultWorkingDirectory)/cpo-datafactory/cpo-adf-dev/ARMTemplateForFactory.json"
-ResourceGroupName "ModernDataPlatform"
-DataFactoryName "cpo-adf-prod"
-predeployment $true
-deleteDeployment $false
azurePowerShellVersion: 'LatestVersion'
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'ARM Template deployment'
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'Visual Studio Enterprise()'
subscriptionId: ''
action: 'Create Or Update Resource Group'
resourceGroupName: 'ModernDataPlatform'
location: 'UK South'
templateLocation: 'Linked artifact'
csmFile: '$(System.DefaultWorkingDirectory)/cpo-datafactory/cpo-adf-dev/ARMTemplateForFactory.json'
csmParametersFile: '$(System.DefaultWorkingDirectory)/cpo-datafactory/cpo-adf-dev/ARMTemplateParametersForFactory.json'
overrideParameters: -factoryName "cpo-adf-prod"
-cpo_kv_properties_typeProperties_baseUrl ""
-cpodatalake_properties_typeProperties_url ""
-cposqlsource_properties_typeProperties_connectionString_secretName ""
deploymentMode: 'Incremental'
- task: AzurePowerShell@5
displayName: 'Clean resources and start ADF triggers'
inputs:
azureSubscription: 'Visual Studio Enterprise()'
ScriptType: 'FilePath'
ScriptPath: '$(System.DefaultWorkingDirectory)/cpo-configs/adf-maintenance.ps1'
ScriptArguments: -armTemplate "$(System.DefaultWorkingDirectory)/cpo-datafactory/cpo-adf-dev/ARMTemplateForFactory.json"
-ResourceGroupName "ModernDataPlatform"
-DataFactoryName "cpo-adf-prod"
-predeployment $false
-deleteDeployment $true
azurePowerShellVersion: 'LatestVersion'
@zbachore
Copy link

This is the best demo on ADF CICD using YAML. Thank you for sharing!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment