Wednesday, October 28, 2020

Editing bacpac file before importing


The bacpac file I have generated from Azure SQL had a reference to an external resource - that I do not require. Hence, when I was importing the database locally it was failing. Clearly, I need to remove the reference to the external data source.

As I do, googled, and got couple of solutions :

  • Change collation of an Azure SQL database by hacking the BACPAC file : Very helpful to know what exactly need to be done to copy an Azure SQL Db to local SQL server. When I tried create the cheksome of the model.xml file - it was saying invalid dacpac file - (quite obvious as mine was a bacpac file not dacpac)
  • Editing a .bacpac file : Then this microsoft article helped me creating a PowerShell script - which did not quite working for me - ( I am on a Windows 10 machine, possibly and using different PowerShell ? - did not get enough time to investigate further).
  • Get-FileHash : PowesrShell to generate checksum for files : Finally, found the command that helped me to generate the checksum for the file as explained in other two articles. (BTW, I had to remove all the reference to the external data source)
voilà - now I need to start my actual task - track the transactions in the database for some front end activity and finally create SQL script to generate test data.