Eoin Campbell
Eoin Campbell

Reputation: 44268

Can you create a SQL Azure BACPAC from a Remote C# Application

I'm working on a tool to allow backup and restore of SQL Azure databases between various local & azure environments.

I have a working version where the BACPAC is created and directly streamed to my Local Developer machine.

But I haven't been able to find a way to create the bacpac and store it directly in Blob Storage using a remote client. Any of the examples I've seen either

OR

Is there a way to trigger the Backup Functionality that's available through the Azure Management Portal (Create Backup (BACPAC) directly to Blob Storage) from a remote client?

Upvotes: 1

Views: 2139

Answers (1)

You should use SQL Azure Database Import Export Service. You can find more about this service here.

For export functionallity you can then use this piece of code:

//Set Inputs to the REST Requests in the helper class          
IEHelper.EndPointUri = @"<address of database endpoint according to its location, e.g. https://by1prod-dacsvc.azure.com/DACWebService.svc for DB located in West US>"; 
IEHelper.ServerName = "<database_server_name>.database.windows.net"; 
IEHelper.StorageKey = "<storage_key>"; 
IEHelper.DatabaseName = "<database_name>"; 
IEHelper.UserName = "<database_user_name>"; 
IEHelper.Password = "<database_password>"; 

//Do Export operation 
string exportBlobPath = IEHelper.DoExport(String.Format(@"https://<storage_name>.blob.core.windows.net/bacpac/{0}.bacpac", IEHelper.DatabaseName)); 
ImportExportHelper IEHelper = new ImportExportHelper(); 

Upvotes: 6

Related Questions