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
- Stream the backup to the local PC, and then re-upload it to Blob Storage
OR
- Rely on having a worker role deployed on Azure to handle process
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?
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();