<p>Depends on where the source data is when considering how you want to initialise the database. </p>

<ol>
<li>If the data pre-exists in another SQL-Azure Database you could create a BACPAC and <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-export#export-to-a-bacpac-file-using-the-azure-portal" rel="nofollow noreferrer">export the file to a blob store in Azure</a>. Then using PowerShell in your pipeline import <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-import#import-from-a-bacpac-file-using-powershell" rel="nofollow noreferrer">the data into your created database</a>. Bare in mind this will be time costly dependent on the amount of data and the size of the database. </li>
<li>If the data is only small, an approach we have used before to build and populate tables is a <a href="https://docs.microsoft.com/en-us/vsts/pipelines/targets/azure-sqldb?view=vsts&amp;tabs=designer" rel="nofollow noreferrer">DACPAC</a>. Here we had the create scripts for our tables and then stored procedures with static reference data stored in insert statements which were run after the DAC built the tables &amp; indexes etc. <a href="https://www.c-sharpcorner.com/article/create-sql-server-database-project-with-visual-studio/" rel="nofollow noreferrer">Here</a> is an example in how to create a DACPAC project in Visual Studio and populate from an exisiting database. Alternatively if you're building from scratch you can add the required database objects to the solution and create them using SQL Statements. </li>
<li>The third option would be streaming data from a source using an Azure Function and blob storage however without knowing more about your set up I can't advise more. </li>
</ol>

<p>Hope that helps </p>

CC BY-SA 4.0
2018-07-31T18:55:15.237Z
I'm going to accept your answer as this is sort of what we went with.  The database already exists on a single developer's machine and what submitting bacpacs to QA to create/init database.  We determined where the data is originating from and we already have an installer that will just insert the data from it's raw form
xtreampb
CC BY-SA 4.0
2018-07-31T16:23:32.983Z
2018-07-31T16:23:32.983Z
Pete Philters
<p>I'm setting up Build Automation for a MS-SQL project.  One of the requirements is to initialize the database with data.  I have them as SQL scripts.  I'm trying to figure out what the best way to inizialize a database after it is deployed using VSTS build and release automation.</p>

<azure-devops>
Initialize database with data
xtreampb
# Initialize database with data

(Asked by: username_0 on 2018-07-30)

I'm setting up Build Automation for a MS-SQL project. One of the requirements is to initialize the database with data. I have them as SQL scripts. I'm trying to figure out what the best way to inizialize a database after it is deployed using VSTS build and release automation.

**Tags:** azure-devops


---

## 1 answers

### Answer by username_1 on 2018-07-31. Score: 1 | Accepted answer

Depends on where the source data is when considering how you want to initialise the database.

1. If the data pre-exists in another SQL-Azure Database you could create a BACPAC and [export the file to a blob store in Azure](https://docs.microsoft.com/en-us/azure/sql-database/sql-database-export#export-to-a-bacpac-file-using-the-azure-portal). Then using PowerShell in your pipeline import [the data into your created database](https://docs.microsoft.com/en-us/azure/sql-database/sql-database-import#import-from-a-bacpac-file-using-powershell). Bare in mind this will be time costly dependent on the amount of data and the size of the database.
2. If the data is only small, an approach we have used before to build and populate tables is a [DACPAC](https://docs.microsoft.com/en-us/vsts/pipelines/targets/azure-sqldb?view=vsts&tabs=designer). Here we had the create scripts for our tables and then stored procedures with static reference data stored in insert statements which were run after the DAC built the tables & indexes etc. [Here](https://www.c-sharpcorner.com/article/create-sql-server-database-project-with-visual-studio/) is an example in how to create a DACPAC project in Visual Studio and populate from an exisiting database. Alternatively if you're building from scratch you can add the required database objects to the solution and create them using SQL Statements.
3. The third option would be streaming data from a source using an Azure Function and blob storage however without knowing more about your set up I can't advise more.

Hope that helps

> **Comments:**
> **username_0**: I'm going to accept your answer as this is sort of what we went with.  The database already exists on a single developer's machine and what submitting bacpacs to QA to create/init database.  We determined where the data is originating from and we already have an installer that will just insert the data from it's raw form  

---

