How to Deploy Azure SQL database using dacpac and Azure DevOps
- Azure SQL Server with a source and target database instance
- GitHub repo
- Visual code for SQL Server Database Objects
- Familiarity about dacpac
- Azure DevOps Account
Since I was an admin on azure, DevOps, I am not sure on the permissions required. Ideally contrubutor access should be enough to implement this solution.
Problem Statement and Solution
We are using dacpac for deploying our SQL artifacts from source to target server/database. The SQL server code, as well as the dacpac, is checked inside the GitHub repo. We need to develop an azure DevOps pipeline that uses the dacpac and does the deployment.
I have found if you change the dacpac location to a custom folder and sync it to the Github repo, we could achieve what we had set out to.
Logical Steps
1. Create a SSDT project
2. Link SSDT to github repo with a local repo
3. Create a folder for dacpac in local repo
4. Add settings in visual studio to point dacpac creation to this folder
5. Build the solution
6. Dacpac should be created in the new folder
7. Push the code and sync it to github repo
8. Verify the new folder is available in github repo
9. Create a devops pipeline with dacpac option
10. Configure and link it to github repo/branch
11. Test and run the pipeline on target server/database
12. SQL Objects should be deployed and should be available on the target server/database
DEMO
1. Create a new repo inside GitHub
2. Create a new SQL Server Database Project
3. Import source database
Full demo available here
ReplyDeletehttps://www.youtube.com/watch?v=rKhEWQK-VQo