Azure / Azure-DataFactory

Other
485 stars 590 forks source link

how to use PrePostDeploymentScript.Ver2.ps1 within CICD ADF #501

Open NewRay99 opened 1 year ago

NewRay99 commented 1 year ago

How am i meant to use this ps1 script in the deployment. the usual build process somehow drops PrePostDeploymentScript.ps1 into the application artifacts folder. however this file isnt copied into the folder the same way?

am i meant to manually take a copy of this version and create a copy task to copy the file to the artifacts folder?


- task: AzurePowerShell@5
              displayName: 'Start triggers and cleanup'
              inputs:
                azureSubscription: '${{parameters.azureSubscriptionSPN}}'
                pwsh: true
                azurePowerShellVersion: LatestVersion
                scriptType: filePath
                scriptPath: '$(Pipeline.Workspace)/datafactory/application/PrePostDeploymentScript.Ver2.ps1'
                scriptArguments:
                  -armTemplate $(Pipeline.Workspace)/datafactory/application/arm-parameters-${{lower(parameters.Stage)}}.json
                  -ResourceGroupName ${{parameters.resourceGroupName}}
                  -DataFactoryName ${{parameters.dataFactoryName}}
                  -predeployment $false
                  -deleteDeployment $true 
soma-ms commented 1 year ago

If I understand the issue correctly, in the build pipeline you are using NPM utility to generate arm-template so it pushes the templates and script to the pipeline artifacts.

You need a release pipeline to deploy the template to factory, please check the guidance here. In that section in step-6 instead of Azure repos artifact you will use Build artifact (which is pipeline artifact the build pipeline).

nwcm commented 1 year ago

I am also unable to get the v2 script in any CICD from NPM. the start-preview doesn't seem to work or adding --preview in any way

soma-ms commented 1 year ago

@nwcm - NPM always get the latest script (same *.ver2.ps1) though the name of the script PrePostDeploymentScript.ps1. And you don't need --preview flag anymore as the script is GA'ed.

nwcm commented 1 year ago

Thanks @soma-ms I will need to confirm as it was seemingly disabling unedited triggers like version1