How to import/export sql azure database from one dabase server to another programmetically? RRS feed

  • Question

  • Hi,

    I am trying to export and import sql azure database. First export it to a temporary blob storage and from there I will import it into another database server. There is a tool in azure portal(import/erport) through which I can do that. But I want to do it programmetically(c#) and trying to create a worker role so that it will execute with a particular schedule. I tried to get some help from different website, but in most of the pages they did not mentioned a particular step by step process. They are just giving some portion of total code. But for executing this what are the additional setup are not mentioned there. most of them are saying to use DAC. But I don't have any idea how to use it. Can anynoe please help me with proper c# code.



    Friday, October 12, 2012 11:57 AM

All replies

  • Hi Saikat,

    Thank you for your question.  

    I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated.  

    Thank you for your understanding and support

    Best Regards,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 15, 2012 8:36 AM
  • Hi Saikat

    I guess you are looking for something like this.. http://azureautobackup.codeplex.com/



    I hope it helps!! If you found this post useful, Please "Mark as answer" or "Vote as Helpful". Thanks much!

    • Proposed as answer by Ashish.Agrawal Monday, October 15, 2012 9:19 AM
    Monday, October 15, 2012 9:19 AM
  • You could use SQL Server 2012 Data Tier Application Framework API to do that. You could download it from http://www.microsoft.com/en-us/download/details.aspx?id=34964. In that framework, you could use DacServices::ExportBacPac to export SQL Azure database and import using DacServices::ImportBacPac. Besides, there is no API which could export the SQL Azure database directly to Azure BLOB storage, there need to be a local temporary output. You could refer to the following sample,

    DacServices dacService = new DacServices("server=<username>;uid=<user name>;password=<password>");
                dacService.ExportBacpac(<file path>, <database name>);

                BacPackage bacpacFile = BacPackage.Load(<file path>, DacSchemaModelStorageType.File);
                dacService.ImportBacpac(bacpacFile, <database name>);

    Tuesday, October 16, 2012 9:28 AM