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 https://ch1prod-dacsvc.azure.com/DACWebService.svc
South Central US https://sn1prod-dacsvc.azure.com/DACWebService.svc
North Europe https://db3prod-dacsvc.azure.com/DACWebService.svc
West Europe https://am1prod-dacsvc.azure.com/DACWebService.svc
East Asia https://hkgprod-dacsvc.azure.com/DACWebService.svc
Southeast Asia https://sg1prod-dacsvc.azure.com/DACWebService.svc
Northwest US http://dacdc.cloudapp.net/DACWebService.svc
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();
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.
client.Import(importInput);
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.