Answers: <p>Ok, after researching some more time, I've found this gem <a href="https://markheath.net/post/backup-restore-sql-database-azure-cli" rel="nofollow noreferrer">https://markheath.net/post/backup-restore-sql-database-azure-cli</a>. In this article author uses <code>az sql db export</code> and <code>az sql db import</code> to save database into BACPAC and restore it back on the clean database. But here comes a pitfall - Azure CLI task v1.0 uses <strong>CMD</strong> so it's not easy to translate from <strong>Bash</strong> syntax to <strong>CMD</strong>, and Azure CLI task v2.0 <em>preview</em> which has option to choose <strong>Bash</strong> 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 <strong>Powershell</strong> if they want to use it.<br>
  So, it's not completely what I was looking for but it does its job. </p>
  
Answers: CC BY-SA 4.0
Answers: 2020-03-04T08:44:55.033Z
Answers: 2020-03-04T08:44:55.033Z
Answers: Sergey Salin
Body: <p>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.<br>
  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.<br>
  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</p>
  
Tags: <azure-devops><azure><azure-pipelines>
Title: How to make .DACPAC from Azure Sql Server using Azure DevOps release pipeline?
UserDisplayName: Sergey Salin
ThreadText: # How to make .DACPAC from Azure Sql Server using Azure DevOps release pipeline?
  
  (Asked by: username_0 on 2020-02-28)
  
  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
  
  **Tags:** azure-devops, azure, azure-pipelines
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-03-04. Score: 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.
  
  
  ---
  
  