Azure devops ADF pre and post deployment script

Prags 1 Reputation point
2022-04-18T23:14:14.837+00:00

I am using pre post deployment script from Azure page in the ADF devops pipeline. The first task uses these parameters.
-armTemplate "$(System.DefaultWorkingDirectory)/<your-arm-template-location>" -ResourceGroupName <your-resource-group-name> -DataFactoryName <your-data-factory-name> -predeployment $true -deleteDeployment $false

Then the ARM deployment and next task uses
-armTemplate "$(System.DefaultWorkingDirectory)/<your-arm-template-location>" -ResourceGroupName <your-resource-group-name> -DataFactoryName <your-data-factory-name> -predeployment $false -deleteDeployment $true.

The third task deletes everything in the ADF. I just wanted to remove the old pipelines that doesn't exist in my master pipeline or ADFPublish branch. Do I have to make any changes in that script to handles this ?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,624 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. KranthiPakala-MSFT 46,642 Reputation points Microsoft Employee Moderator
    2022-04-19T19:42:56.147+00:00

    Hello @Prags ,

    Thanks for the question and using MS Q&A platform.

    The -deleteDeployment flag is used to specify the deletion of the ADF deployment entry from the deployment history in ARM. In the post-deployment script, you will specify the below variation of parameters/arguments which includes code to delete resources (unwanted resources like pipelines, datasets, dataflows, linked services, integration runtimes) that have been removed in the current deployment (Nothing but deletes resources which are present in last deployment(ARM) but not in current deployment(ARM) from deployment history).

    Post-deployment script - which will start your triggers once after the cleanup (delete) of unwanted resources is completed.

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

    This will execute below piece of code from the script provided in the public documentation:

    194433-image.png

    This is a sample script provided by ADF product team, but you can alter the script as per your custom requirement. In case if you have few resources like pipelines/datasets/linked services that are removed in the current deployment but were present in the previous deployment then you can just use the same post-deployment script provided in the doc to get rid of the unwanted resources.

    Hope this clarifies.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.