Azure Storage Account (Blob Storage) directly into Azure SQL

Prerequisites

Generate the SAS Token

In Azure Portal:

  1. Go to your Storage Account → Containers → YourContainer → YourFile.csv

  2. Click Generate SAS

  3. Allow Read permission

  4. Set the expiry date/time

  5. Click Generate SAS Token and URL

  6. Copy the Blob SAS URL — it will look like this:

    https://mystorage.blob.core.windows.net/mycontainer/myfile.csv?sv=2025-01-01&st=2025-11-05T00%3A00Z&se=2025-11-06T00%3A00Z&sr=b&sp=r&sig=xxxxxxxxxxxxxxxxx

Create a Database Scoped Credential

Run this in your SQL Database:

CREATE DATABASE SCOPED CREDENTIAL AzureBlobCredential
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
SECRET = 'sv=2025-01-01&st=2025-11-05T00%3A00Z&se=2025-11-06T00%3A00Z&sr=b&sp=r&sig=xxxxxxxxxxxxxxxxx';

⚠️ Use only the part after the question mark (?) from your SAS URL for the SECRET.

Create an External Data Source

This tells SQL where to fetch the file from:

CREATE EXTERNAL DATA SOURCE MyAzureBlobStorage
WITH (
    TYPE = BLOB_STORAGE,
    LOCATION = 'https://mystorage.blob.core.windows.net/mycontainer',
    CREDENTIAL = AzureBlobCredential
);

Import the CSV File with BULK INSERT

Now you can import directly:

BULK INSERT dbo.MyTargetTable
FROM 'myfile.csv'
WITH (
    DATA_SOURCE = 'MyAzureBlobStorage',
    FORMAT = 'CSV',
    FIRSTROW = 2,
    FIELDTERMINATOR = ',',
    ROWTERMINATOR = '\n',
    TABLOCK
);

Tips:

Verify Import

SELECT TOP 10 * FROM dbo.MyTargetTable;