SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Moving to an Azure SQL Database via Command Line

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.

UPDATEDBACPAC

OUTPUTS

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"

moveit

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.

movedAzure

 


Filed under: Azure, Azure SQL DB Tagged: Azure, Azure SQL DB, CMD, Migration

All About SQL

I am a Senior DBA with interest in MS technology especially SQL Server and Azure. During 2015 I was mentored by Paul Randal – Data Platform (SQL Server) MVP and during 2016 I completed my SQLskills Immersion training on Internals and Performance Tuning. When I am not working I am in the gym burning calories.

Comments

Leave a comment on the original post [blobeater.blog, opens in a new window]

Loading comments...