3

How to programmatically (C#) extract a BACPAC file from a SQL Azure Database?

I was thinking in terms of creating a azure job to extract this bacpack file and save it to my storage account whenever a specific exception happens... I'm trying to get a hold of a heinsenbug and a snapshot of the database at the time of the event would be very helpful.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Leonardo
  • 10,737
  • 10
  • 62
  • 155

1 Answers1

5

Add microsoft.sqlserver.dac.dll

SqlConnectionStringBuilder csb = new SqlConnectionStringBuilder();
csb.DataSource = "servername";
csb.Password = "whatever";
csb.UserID = "whatever";

DacServices ds = new DacServices(csb.ConnectionString);
ds.ExportBacpac(@"C:\backup\backup.bacpac");
Renato Afonso
  • 654
  • 6
  • 13