When you need to create an archive of an Azure SQL database, you can export the database schema and data to a BACPAC file. A BACPAC file can be stored in Azure blob storage or in local storage in an on-premises location and later imported back into Azure SQL Database or into a SQL Server on-premises installation.
Let's learn some of the ways to export BACPAC file.
There is a command line tool that you can also choose to perform the import/export. The latest version is here. Sqlpackage will be installed to “C:\Program Files\Microsoft SQL Server\150\DAC\bin” directory.
Example import/export commands
sqlpackage.exe /Action:Export /ssn:[server].database.windows.net /sdn:[database] /su:[user] /sp:[password] /tf:"C:\Temp\database.bacpac"
sqlpackage.exe /Action:Import /tsn:[server].database.windows.net /tdn:[database] /tu:[user] /tp:[password] /sf:"C:\Temp\database.bacpac"
The public documentation introduce SQLPackage utility:
https://docs.microsoft.com/en-us/azure/sql-database/sql-database-export#export-to-a-bacpac-file-using-the-sqlpackage-utility
You can use New-AzSqlDatabaseExport cmdlet to export database bacpac file.
Example:
Check the status of Database export using the below command:
Let's learn some of the ways to export BACPAC file.
Export BACPAC using Azure Portal
- Open your SQL Database and select Export.
- Fill the parameters as shown below.
- Select your storage account container & enter your SQL Server admin login.
- To check the status of your database export. Open your SQL Database server containing the database being exported. Go to Settings and then click Import/Export history
Export BACPAC using SSMS
- Login Azure SQL Database by SSMS.
- Right-click the database -> Tasks -> Export Data-tier Application
- Save the .bacpac file into local disk.
Export BACPAC using SQLPackage
There is a command line tool that you can also choose to perform the import/export. The latest version is here. Sqlpackage will be installed to “C:\Program Files\Microsoft SQL Server\150\DAC\bin” directory.
Example import/export commands
sqlpackage.exe /Action:Export /ssn:[server].database.windows.net /sdn:[database] /su:[user] /sp:[password] /tf:"C:\Temp\database.bacpac"
sqlpackage.exe /Action:Import /tsn:[server].database.windows.net /tdn:[database] /tu:[user] /tp:[password] /sf:"C:\Temp\database.bacpac"
The public documentation introduce SQLPackage utility:
https://docs.microsoft.com/en-us/azure/sql-database/sql-database-export#export-to-a-bacpac-file-using-the-sqlpackage-utility
Export BACPAC using Powershell
You can use New-AzSqlDatabaseExport cmdlet to export database bacpac file.
Example:
$exportRequest = New-AzSqlDatabaseExport -ResourceGroupName "RG01" -ServerName "Server01" -DatabaseName "Database01" -StorageKeyType "StorageAccessKey" -StorageKey "StorageKey01" -StorageUri "http://account01.blob.core.contoso.net/bacpacs/database01.bacpac" -AdministratorLogin "User" -AdministratorLoginPassword "secure password"
Check the status of Database export using the below command:
$exportStatus = Get-AzSqlDatabaseImportExportStatus -OperationStatusLink $exportRequest.OperationStatusLink [Console]::Write("Exporting") while ($exportStatus.Status -eq "InProgress") { Start-Sleep -s 10 $exportStatus = Get-AzSqlDatabaseImportExportStatus -OperationStatusLink $exportRequest.OperationStatusLink [Console]::Write(".") } [Console]::WriteLine("") $exportStatus
I like the way you get the things in your post for sharing it. In this post you gave me good information. Thanks for it.Mexico Export Data
ReplyDeleteGreat Article. Thank you for providing such a unique and valuable information to your readers. I really appreciate your work. shipping from China to Canada
ReplyDeleteYou have a genuine capacity to compose a substance that is useful for us. You have shared an amazing post about china export data Much obliged to you for your endeavors in sharing such information with us. china export data
ReplyDeleteIt's really a great and helpful bit of data that you have shared here. I'm glad that you just imparted this accommodating data to us. Kindly share these types knowledge with us. Much thanks to you for sharing it. Urgent Document Delivery
ReplyDeleteImpressive and powerful suggestion by the author of this blog are really helpful to me.
ReplyDeletebuy perfume online uk