microsoft / DACExtensions

DACExtensions contains samples that extend Data-Tier Applications using DacFx. These samples include deployment contributors and static code analysis rules that can be used with Visual Studio as well as examples of how to use the DacFx public mode
MIT License
125 stars 41 forks source link

Add powershell script to remove master key info from a .bacpac #9

Closed pensivebrian closed 6 years ago

pensivebrian commented 7 years ago

When exporting a .bacpac from Azure SQLDB with auditing enabled, the .bacpac will contain a master key without a password in the model.xml. A master key without a password is an Azure SQLDB only feature, so it's presence prevents being able to import the .bacpac into an on-premise SQL Server database.

This script works around this limitation by extracting the model.xml and origin.xml from the .bacpac, removing the references to the master key, and creating a new .bacpac with the updated model.xml and origin.xml.

The resulting .bacpac can then be imported to an on-premise database.