sql-serverexportazure-sql-databaseazure-blob-storagebacpac

How to export on premise database as bacpac directly to AZURE blob using command line


We were able to create the bacpac using the below command,

C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin>

sqlpackage.exe /Action:Export /ssn:. /sdn:demo /tf:d:\bacpac\demo.bacpac

However we want to automate the below action,

enter image description here

Also can this be done via SSMS using something similar

BACKUP DATABASE demo

TO URL = @FullName

WITH CREDENTIAL = democredential;


Solution

  • You can use Azcopy to upload those bacpac files to an Azure BLOB Storage account as shown below:

    AzCopy /Source:"d:\bacpac" /Dest:"https://exampleaccount.blob.core.windows.net/bacpacs" /DestKey:storageaccountkey /Pattern:*.bacpac
    

    Hope this helps.