I have a bacpac file from a read-only database hosted on Azure. When imported to a new server the database is also read-only.
I’ve tried looking for answers with no luck.
How can I change it to a writeable?
azure-sql-databasesql server
I have a bacpac file from a read-only database hosted on Azure. When imported to a new server the database is also read-only.
I’ve tried looking for answers with no luck.
How can I change it to a writeable?
Best Answer
It doesn't look like there are any supported ways to change this. However...
I noticed that the bacpac file is just a zip archive, so I unzipped it. The basic structure of the folder looks like this:
I then used KDiff to diff two bacpacs of the exact same data - one that was read-write, and one that was read-only. The main difference of substance was in model.xml:
So you should be able to remove those two lines* from the bacpac, and then import it, and it will be read-write! I attempted this on my local Developer Edition copy of SQL Server 2016, but got this error message:
Which led me to this blog post: Azure SQL Database Support - Editing a .bacpac file
So I followed the instructions there, running this PowerShell script to generate a new checksum:
Then updating the Origin.xml checksum line at the end:
Zipped all the files again (I used the "Deflate" algorithm in 7-zip), and then imported the database. It came in perfectly as a normal, read-write database.
*Note: I didn't explicitly enable snapshot isolation, that happens automatically when you set a database to read-only. Not even Paul White is sure why, so what hope do the rest of us have? For more, see Snapshot_isolation_state_desc on a Read only/Stand by Database