Skip to main content
Remove data from BACPAC file
  1. Posts/

Remove data from BACPAC file

·158 words·1 min
Christoph Petersen
Author
Christoph Petersen

Today I needed to create a test database for one of the products I’m working on. In the backend it uses LINQ to SQL against a SQL Azure Database. Exporting the production database and cleaning it up with millions of records in it turned out to be not the most efficient way of creating an empty test database.

I ended up modifiying the BACPAC file that is generated by the export functionality available through Azure Portal (and PowerShell / CLI).

To simply remove all data and just keep the model follow these steps:

  1. Download the .bacpac file from blob storage
  2. Unzip the .bacpac file (you may have to rename to .zip)
  3. Delete everything under /Data
  4. Replace the content of _rels/.rels with the following
<?xml version="1.0" encoding="utf-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
</Relationships>`
  1. Zip everything (but make sure to not include a directory in the archive)

You can now use PowerShell or CLI to import the empty BACPAC file to your database.

Related

Moving on: Leaving Microsoft

·138 words·1 min
After spending close to eight years in different roles at Microsoft, my time with Microsoft has come to an end. I accepted a new role, starting on May 1st, as Chief Technology Officer with HorseAnalytics an animal tech startup focused on providing a telemetry data platform for horses.

Cloud Adoption Framework for Azure

·120 words·1 min
Governance is one of the major adoption challenges when it comes to cloud computing. Organizations find themselves “not ready” to consume cloud services whether that perception is more a gut feeling or comes from experience.

Automation in Azure

·1125 words·6 mins
Deploying resources and workloads at scale requires a healthy amount of automation. Automation helps to deliver consistent and repeatable results. I’ve tried to categorize some of the technology and provide some pointers to areas of application and pros and cons.