SQL Database Scheduled Backup to Azure Blob

December 12, 2025
SQL ServerAzureBackupAutomation
In this article, we’ll walk through how to automate backups of multiple SQL Server databases directly to Azure Blob Storage using SQL Server Agent. This is ideal for hybrid or cloud-first architectures where backups must be offloaded to Azure for safe keeping.

Step 1: Create an Azure Blob Container & SAS Token

  1. Go to Azure Portal
  2. Navigate to your Storage Account → Containers
  3. Create a new container (e.g.,
    )
  4. (Optional) If hierarchical namespace was enabled, you can create folders (year-wise, month-wise) inside.
  5. Generate a SAS token for the container with:
    • Permissions: Write, List, Create, Add
    • Expiry: Set it for a long duration (e.g., 1 year)
  6. Copy the Container URL and SAS token.

Step 2: Create a Credential in SQL Server

In SSMS, run the following T-SQL command. Replace the URL and Secret with yours.
Note: The SECRET must include the leading
.

Step 3: Write the Backup Script

Run the following script to create stored procedure or just use it in the job step. It automates backup for all user databases.
This script:
  1. Loops through all non-system databases.
  2. Generates a unique filename with timestamp (
    ).
  3. Backs up directly to the Azure Blob URL with compression.

Step 4: Create a SQL Server Agent Job

  1. Open SQL Server Management Studio (SSMS).
  2. Navigate to SQL Server Agent → New → Job...
  3. Name it (e.g.,
    ).
  4. Steps Tab:
    • Add a new step.
    • Type: Transact-SQL.
    • Database:
      .
    • Paste the script from Step 3.
  5. Schedules Tab:
    • Create a recurring schedule (e.g., Daily at 12 AM).
  6. Save the job.

Output Example

Once the job runs, you’ll see
files in your Azure Blob container: