How to implement AgileSqlClub AdditionalDeploymentContributors in Devops Pipeline

43 Views Asked by At

We want to deploy a synapse serverless pool to another stage in the dtap environment. Therefore, we have setup a DevOps pipeline where we make a dacpac of the current serverless pool and then make a SQL compare to the environment where we want to detect the differences between current and target environment. in essence this is not difficult, and we manage to do that, but we want only some objects (for instance a list of tables and views) from the current serveless pool.

Question

  1. is this possible with the current SqlAzureDacpacDeployment@1, DeploymentAction: 'Script'?
  2. If not, I found this code AgileSqlClub.DeploymentFilterContributor, but then I have troubles in getting the dll found
 - task: SqlAzureDacpacDeployment@1
   name: ScriptCompare
   displayName:  script change 
   inputs:
       AuthenticationType: 'server'
       azureSubscription:  '$(az_service_connection_name)'
       deployType: 'DacpacTask'
       DeploymentAction: 'Script' 
       ServerName: ${{ parameters.serverName }}
       DatabaseName: ${{ parameters.databaseName }}
       AuthScheme: sqlServerAuthentication
       DacpacFile: $(Pipeline.Workspace)\GeneratedOutputFiles\sql-sl-datahub.dacpac # ${{ parameters.databaseName source}}
       SqlUsername: $(sqlUsername)
       SqlPassword: $(sqlPassword)          
       IpDetectionMethod: 'AutoDetect'       
       AdditionalArguments: '/p:AdditionalDeploymentContributors="AgileSqlClub.DeploymentFilterContributor" /p:AdditionalDeploymentContributorPaths="$(Pipeline.Workspace)\drop\SqlPackageFilter" /p:AdditionalDeploymentContributorArguments="SqlPackageFilter0=KeepName(.*yTabl.*)" /p:ExcludeObjectTypes=Users;Logins;RoleMembership;Permissions /p:DropObjectsNotInSource=true'

But this causes, whatever I do, this error in the DevOps pipeline.

Starting: script change
....
....
Generating publish script for database 'xxxxxx' on server 'xxxxxxx'.
Time elapsed 0:00:21.58
##[error]*** An error occurred during deployment plan generation. Deployment cannot continue.
**##[error]Error SQL0: Required contributor with id 'AgileSqlClub.DeploymentFilterContributor' could not be loaded.**
##[error]System.Management.Automation.RemoteException
##[error]Contributor initialization error.
##[error]The Azure SQL DACPAC task failed. SqlPackage.exe exited with code 1.Check out how to troubleshoot failures at https://aka.ms/sqlazuredeployreadme#troubleshooting-
Finishing: script change

I tried to upload the related dll's into an artifact of the pipeline.

  - download: current
    artifact: drop`

But issue that the dll could not be found (my interpretation) is still there.

Would be very nice if someone could explain to me how to use that

'/p:AdditionalDeploymentContributors="AgileSqlClub.DeploymentFilterContributor" /p:AdditionalDeploymentContributorPaths="$(Pipeline.Workspace)\drop\SqlPackageFilter" 

proper in a pipeline.

1

There are 1 best solutions below

0
Miao Tian-MSFT On

You can check the DeploymentContributorFilterer, it introduces the Basic Usage. Download the latest release from GitHub or build yourself and put the dll in the same folder as sqlpackage.exe.

In the Note:

Windows may block the AgileSqlClub.DeploymentFilterContributor.dll after downloading. You will need to view the file properties and Unblock it.

So, if you are using the self-hosted agent, you can unblock it manually. If you are using the Microsoft hosted agent, you can build the code and use the resulting dll. You can check more details and a screenshot in this issue.