1

I'm using Terraform to create my environment and I'd like to deploy Azure Sql Server along with other things. I use terraform so I can easily destroy all deployed things and reduce costs when I'm not using them.
So, I decided that I can add Azure Sql Server into my Terraform file but I need to store my information into backup file so I can restore it with "Azure SQL Database deployment" task from pipeline. Hovewer, I haven't find any indication that it is possible to create a .DACPAC from within Azure DevOps.
So, is there a way to create and save a backup of my database (preferrably, into a blob storage) from Azure DevOps pipeline? I looked into azure shell (az sql database), but haven't find anything of value

2

Ok, after researching some more time, I've found this gem https://markheath.net/post/backup-restore-sql-database-azure-cli. In this article author uses az sql db export and az sql db import to save database into BACPAC and restore it back on the clean database. But here comes a pitfall - Azure CLI task v1.0 uses CMD so it's not easy to translate from Bash syntax to CMD, and Azure CLI task v2.0 preview which has option to choose Bash as an interpreter doesn't have az installed (it's probably a bug and already has a post on uservoice) so one needs to rewrite the script into Powershell if they want to use it.
So, it's not completely what I was looking for but it does its job.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.