I have moved many databases to Azure via different methods but I recently came across a new way. Well technically it’s not new, I should say, newly found. The migration was done via the command line which is not exactly ground breaking but it’s nice to have another option.
The idea behind this is simple. Create the bacpac via command line using sqlpackage.exe with the action as export then do an import action into Azure.
Create The Bacpac
This is the command line to create a bacpac.
"C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe" /Action:Export /SourceServerName:SourceSQL1 /SourceDatabaseName:SQLskillsWaitTypeAnalysis /TargetFile:"c:\Temp\AzureTestExport.bacpac"
I use the SqlPackage.exe found within my 140 folder and use the Action Export to create a bacpac of the database called SQLskillsWaitTypeAnalysis which dumps it into the C:\Temp\ folder.
Now Move It
The last phase is to move this bacpac to Azure. For simplicity I decided to use the server admin account on the Azure SQL Server where I establish a connection to Azure whilst picking up the bacpac file from the location shown above.
"C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin\SqlPackage.exe" /Action:Import /TargetServerName:Yoursql01.database.windows.net /TargetDatabaseName:AzureDB /TargetUser:ArunSirpal /TargetPassword:***** /SourceFile:"c:\Temp\AzureTestExport.bacpac"
How cool is that? I connect to the server via SSMS (SQL Server Management Studio) just to confirm the database is where I expect it to be.