Sample pre- and post-deployment script

APPLIES TO: Azure Data Factory Azure Synapse Analytics

The following sample demonstrates how to use a pre- and post-deployment script with continuous integration and delivery in Azure Data Factory.

Install Azure PowerShell

Install the latest Azure PowerShell modules by following instructions in How to install and configure Azure PowerShell.

Warning

Make sure to use PowerShell Core in ADO task to run the script

Pre- and post-deployment script

The sample scripts to stop/ start triggers and update global parameters during release process (CICD) are located in the Azure Data Factory Official GitHub page.

Note

Use the PrePostDeploymentScript.Ver2.ps1 if you would like to turn off/ on only the triggers that have been modified instead of turning all triggers off/ on during CI/CD.

Script execution and parameters

The following sample script can be used to stop triggers before deployment and restart them afterward. The script also includes code to delete resources that have been removed. Save the script in an Azure DevOps git repository and reference it via an Azure PowerShell task the latest Azure PowerShell version.

When running a pre-deployment script, you will need to specify a variation of the following parameters in the Script Arguments field.

-armTemplate "$(System.DefaultWorkingDirectory)/<your-arm-template-location>" -ResourceGroupName <your-resource-group-name> -DataFactoryName <your-data-factory-name> -predeployment $true -deleteDeployment $false

When running a post-deployment script, you will need to specify a variation of the following parameters in the Script Arguments field.

-armTemplate "$(System.DefaultWorkingDirectory)/<your-arm-template-location>" -ResourceGroupName <your-resource-group-name> -DataFactoryName <your-data-factory-name> -predeployment $false -deleteDeployment $true

Note

The -deleteDeployment flag is used to specify the deletion of the ADF deployment entry from the deployment history in ARM.

Azure PowerShell task

Next steps