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

送分小仙女□ 提交于 2019-12-23 03:57:05

问题


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?


回答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(); 


来源:https://stackoverflow.com/questions/17588450/can-you-create-a-sql-azure-bacpac-from-a-remote-c-sharp-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!