Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AzureDevOps pipeline and sqlpackage

All,

I would like to create a DACPAC file containing the Schema of the target database during the CI process. I can use this as a baseline schema to create a Testbed against which I can test the scripts in the release.

SqlPackage.exe /TargetFile:"C:\AzureDevOps\AdventureWorks.dacpac" /Action:Extract /SourceServerName:"SQL2016" /SourceDatabaseName:"AdventureWorks2016"

SqlPackage.exe /SourceFile:"C:\AzureDevOps\AdventureWorks.dacpac" /Action:Publish /TargetServerName:"SQL2016" /TargetDatabaseName:"AdWorks"

I can use the above scripts to create the DACPAC and then deploy the DACPAC to create the testbed.

I don't know how to incorporate this step in the AzureDevOps pipeline. I searched for the sqlpackage task but I could not find it.

Perform SQL server actions in Azure Pipelines or TFS

Can others throw some light on how to accomplish this?

like image 353
Gopinath Rajee Avatar asked Oct 20 '25 02:10

Gopinath Rajee


1 Answers

SqlPackage executable needs to be installed in the Agent Machine inorder to execute the SqlPackage command. I'm not sure that HostedAgent having this Executable. So I'd recommend by creating our own Agent, where the Sqlpackage is installed. Then you can execute the scripts in AzureDevOps using your own Agent.

If you are using Azure SQL Database there is a default task available, where you can easily deploy the DACPAC file

enter image description here

like image 194
Jayendran Avatar answered Oct 23 '25 00:10

Jayendran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!