Geeks With Blogs
Sean Barlow

The first thing we need to do is set up a service reference to Import Service here are the URL’s for the different datacenters. You will need to use the datacenter that your you have created your SQL Azure Server in. 
North Central US
South Central US
North Europe
West Europe 
East Asia   
Southeast Asia
Northwest US
Once we have setup, a service reference it will be uncomplicated to execute an import. You will need to have already uploaded the bacpac file to Blob storage to perform the import. The first thing we need to do is create our service client. I have named my service reference ImportService. 

var client = new ImportService.DACWebServiceClient();

Once the service client has been created, we need to create an ImportInput object and populate it with the appropriate values. 

var importInput = new ImportService.ImportInput();

importInput.AzureEdition = "Web";

importInput.DatabaseSizeInGB = 5;

importInput.ConnectionInfo = new ImportService.ConnectionInfo();

importInput.ConnectionInfo.DatabaseName = "YourDatabaseName";

importInput.ConnectionInfo.Password = "YourPassword";

importInput.ConnectionInfo.ServerName = "YourServerName";

importInput.ConnectionInfo.UserName = "YourUserName";

Now we need to setup or blob credentials. You can use either a shared access key or your storage access key. 

var credentials = new ImportService.BlobStorageAccessKeyCredentials();

credentials.StorageAccessKey = "YourStorageAccessKey";

credentials.Uri = "Your Uri to the bacpac located in blob storage";


var sharedCredentials = new ImportService.BlobSharedAccessKeyCredentials();

sharedCredentials.SharedAccessKey = "YourSharedAccessKey";

sharedCredentials.Uri = "Your Uri to the bacpac located in blob storage";

We then set the credentials on the importInput object.

importInput.BlobCredentials = credentials;


Once we have everything setup we just need to call the Import method with the inputimport object as a parameter.
This call also can be done asynchronously which I recommend. This should get you started using the import service. I will do a follow up with the export service.
Posted on Sunday, March 11, 2012 3:06 PM | Back to top

Comments on this post: Import Bacpac into SQL Azure using Code executed from the cloud

# re: Import Bacpac into SQL Azure using Code executed from the cloud
Requesting Gravatar...
Hey man, thanks a lot for your elaboration!
Left by N on Mar 04, 2014 8:57 AM

Your comment:
 (will show your gravatar)

Copyright © SeanBarlow | Powered by: