azure-devopsazure-sql-databasedacpacbacpac

Sqlproj deployment to AzureSql (dacpac vs bacpac)


The Situation

I have an Azure Devops build pipeline that is building and deploying to an existing AzureSql Database instance via the outputted .dacpac.

I would like to have the ability to run a script or execute API calls to create new AzureSql database instances based on that project. I have found the New-AzSqlDatabaseImport powershell cmdlet that ALMOST lets me do that, requiring a .bacpac rather than a .dacpac. I attempted to use the .dacpac and naturally the process failed.

The Question

  1. Can I output a .bacpac from my SqlProj build process?
  2. Alternatively is there a way to create a new database and have that database schema imported from the dacpac in a relatively smooth elegant fashion?

Solution

  • What we have gone with is the following:

    1. Host a "template" database alongside the other databases.
    2. Update the "template" database during each update cycle with the dacpac changes.
    3. On new user/organization creation, execute single call powershell script that performs a quick copy of the "template" database. New-AzSqlDatabaseCopy

    This appears to go faster than separate provision and dacpac deploy, and is a single call to execute. In the future the powershell execution is likely to be changed to an Azure API call.