Azure sql db deployment of dacpac with reference to another dacpac in Azure DevOps

Jay V 21 Reputation points
2022-02-03T22:35:29.36+00:00

I have 2 separate schemas in my Azure Sql database, each for a separate project. There are 2 Visual Studio solutions, one for each: Sln1 and Sln2. Since there is a dependency from one of the views defined in Sln1 to a table in Sln2, there is a dacpac reference to Sln2.dacpac defined under the 'References' of the Sln1.

As a Sln1 developer I am trying to deploy the Sln1 to the database using an Azure DevOps release pipeline. In the release pipeline, I have Sln2.dacpac co-located with Sln1.dacpac in the staging directory path:$(System.DefaultWorkingDirectory)/Deploy/DB. In the Azure SQL Dacpac Task, only Sln1.dacpac is specified as the dacpac file to deploy.

However, the release pipeline attempts to deploy Sln2.dacpac to the database since it is part of the reference of Sln1.
Is there a way to only deploy Sln1 dacpac? Or is it not possible due to the possibility of breaking the integrity during the deployment?

Thanks for any insights.

Azure SQL Database
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 29,017 Reputation points Microsoft Employee
    2022-02-07T20:35:36.483+00:00

    Hi, JayaVenkatasubramanian-2440 Thanks for posting your query in Microsoft Q&A.
    I understand that you have two different databases and both have a dependency on each other and you want to deploy only a single dacpac, Please correct me if thats not accurate.

    The dacpac deployment is a whole-database operation, this can only be altered by deployment contributors or SQLPackage command line flags (properties).
    It gets messy quickly, so the first question is why are we wanting to only deploy a part of the SQL database?

    Beyond validating that this is truly necessary, it can be accomplished. By having a view in Sln1 that references the contents of Sln2, the 2 are completely dependent on each other. If you require an independent development component of a portion of the database, further break apart Sln1 to the components that do not rely on Sln2 (now called Sln3), and make Sln1 dependent on Sln2 and Sln3. Sln3’s dacpac can be independently built and deployed ONLY in conjunction with /p:DropObjectsNotInSource:False. Removing objects from Sln3 will not impact the database and this will be done manually, but components missing from Sln1 and Sln2 will not be removed during the deployment.

    also please refer Add Database Reference Dialog Box - SQL Server Data Tools (SSDT) | Microsoft Learn

    Regards
    Geetha