How to back up Azure SQL DB into BAK file?

Justin Doh 880 Reputation points
2025-12-11T23:07:08.4066667+00:00

I am trying to create a Bak file format from Azure SQL DB into Azure Storage (like Blob storage) on a daily basis for an external client.

Previously, I had an external client to log into that Azure SQL DB to perform query, but it appears that it is too slow.

So, our team decided to have an external client have an access to BAK file so they can get the file and restore into their SQL DB.

I realized that Azure SQL DB backs up into Bacpac file format, not Bak format.

I am using Azure Data Factory to move data, and I am not sure ADF can be used to do the task.

Please let me know the best practice to generate Bak file from Azure SQL DB and push that file into Azure Blob storage.

Thanks.

Azure SQL Database
{count} votes

Answer accepted by question author
  1. Erland Sommarskog 129.1K Reputation points MVP Volunteer Moderator
    2025-12-17T21:55:38.9633333+00:00

    What does it mean that 'it will append to the existing backup file, so there are multiple backups in the same file'?

    Exactly.

    You can avoid this by adding INIT:

    BACKUP DATABASE YourDB TO DISK = 'D:\Backups\YourDB.bak' WITH COMPRESSION, INIT;
    

    This will overwrite the existing file and delete the existing backup file.

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Q&A Assist
    2025-12-11T23:08:17.5966667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Azure SQL Database does not support direct backup to a BAK file format. Instead, it uses BACPAC files for exporting databases. A BACPAC file is a ZIP file that contains the metadata and data from the database, and it can be stored in Azure Blob storage or locally.

    To achieve your goal of creating a backup file for your external client, you can follow these steps:

    1. Export the Database to a BACPAC File: You can use SQL Server Management Studio (SSMS), Azure Data Studio, or the SQLPackage utility to export your Azure SQL Database to a BACPAC file. This file can then be stored in Azure Blob storage.
      • For example, using SSMS, you can right-click on the database, select Tasks, and then Export Data-tier Application... to create the BACPAC file.
    2. Store the BACPAC File in Azure Blob Storage: During the export process, you can choose to save the BACPAC file directly to an Azure Blob storage container.
    3. Automate the Process: If you want to automate this process on a daily basis, consider using Azure Data Factory (ADF) to orchestrate the export of the database to a BACPAC file and then move it to Azure Blob storage. While ADF does not directly create BAK files, it can facilitate the export of BACPAC files.
    4. Client Access: Once the BACPAC file is in Azure Blob storage, your external client can access it for restoration into their SQL Database or SQL Server instance.

    For more details on exporting to a BACPAC file and using Azure Blob storage, you can refer to the documentation provided by Microsoft.


  2. Pilladi Padma Sai Manisha 595 Reputation points Microsoft External Staff Moderator
    2025-12-12T01:20:50.1566667+00:00

    Hi Justin Doh,
    Thankyou For Reaching Microsoft Q&A!
    Azure SQL Database doesn't support native .BAK file backups like on-premises SQL Server these are exclusive to SQL Server instances or Azure SQL Managed Instance. Instead, it exports to BACPAC files, which include both schema and data and work well for your client's restore needs.​

    Manual BACPAC Export Steps:

    Log into the Azure portal, navigate to your SQL server, select the database, and click Export on the Overview page. Choose your Blob storage account/container, provide a filename (like "DB-YYYYMMDD.bacpac"), and start the process max 200GB per file.​

    Daily Automation (Skip ADF):

    Azure Data Factory handles data copying but not BACPAC exports, so use Azure Automation Runbook instead:

    text
    # PowerShell in Runbook
    $exportUrl = "https://yourstorage.blob.core.windows.net/container/DB-$(Get-Date -f yyyyMMdd).bacpac?SAS_TOKEN"
    New-AzSqlDatabaseExport -ResourceGroupName "your-rg" -ServerName "yourserver" -DatabaseName "yourdb" -StorageKeyType "StorageAccessKey" -StorageKey "yourkey" -StorageUri $exportUrl -AdministratorLogin "admin" -AdministratorLoginPassword (ConvertTo-SecureString "pass" -AsPlainText -Force)
    

    Schedule daily, add retention cleanup (delete files >7 days).​

    Quick no-code alternative: Logic Apps with Recurrence trigger > "Export Database" action > save to Blob.​

    Client Access & SQLPackage Option:

    Share a read-only SAS token for Blob access they restore via SSMS (Databases > Tasks > Import Data-tier Application). For large DBs or more control, download SQLPackage.exe and run exports locally before uploading:

    text
    sqlpackage.exe /Action:Export /SourceServerName:"server.database.windows.net" /SourceDatabaseName:"db" /SourceUser:"admin" /SourcePassword:"pass" /TargetFile:"output.bacpac"
    

    BACPACs aren't full backups (use Azure's automated ones for PITR), but perfect for external sharing. Test restores end-to-end!​

    I hope this helps! If you have more questions or need further assistance, feel free to ask!

    0 comments No comments

  3. Erland Sommarskog 129.1K Reputation points MVP Volunteer Moderator
    2025-12-12T19:33:17.17+00:00

    As Pilladi points out, you cannot produce BAK files from Azure SQL Database.

    There is however an alternative to BACPACs, and that is CREATE DATABASE AS COPY OF, which even can used to copy databases across tenants and subscriptions. Read further here: https://techcommunity.microsoft.com/blog/azuredbsupport/how-to-copy-azure-sql-database-to-a-different-subscription-and-different-tenant/3965985

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.