A Storage Account (with a container and your CSV file uploaded)
A SAS token (Shared Access Signature) that allows read access
Access to your Azure SQL Database or SQL Server (2019+)
In Azure Portal:
Go to your Storage Account → Containers → YourContainer → YourFile.csv
Click Generate SAS
Allow Read permission
Set the expiry date/time
Click Generate SAS Token and URL
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=xxxxxxxxxxxxxxxxxRun 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.
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
);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:
Make sure MyTargetTable exists first — create it with matching column definitions.
You can also use FORMATFILE if you need precise column mapping.
SELECT TOP 10 * FROM dbo.MyTargetTable;