(+351) 21 24 10006  ·  info@bconcepts.pt
Carnaxide, Lisbon

How to load CSV files into Azure SQL in Azure Data Factory

João Barros 09 de August de 2026 3 min read

This tutorial shows how to load CSV files stored in Azure Blob Storage into an Azure SQL table using Azure Data Factory, with light transformations and error handling. Learning to automate this task is useful to integrate source data into ETL/ELT pipelines and ensure repeatable and observable loads.

Prerequisites

  • Azure account with permissions to create resources
  • An Azure Storage Account with a container and some CSV files
  • An Azure SQL Database instance with a target table
  • An Azure Data Factory instance (or permissions to create one)
  • Azure Key Vault recommended for secrets (optional)

Step 1: Create Linked Services

Linked Services tell ADF how to connect to sources/destinations. Create a Linked Service for Azure Blob Storage and another for Azure SQL Database. Use the ADF interface (Manage > Linked services) and test the connection. If using secrets, point to Azure Key Vault or use Managed Identity for increased security.

Step 2: Create Datasets for source and sink

Create a Dataset of type Azure Blob Storage pointing to the CSV files (name pattern or folder). Create a Dataset of type Azure SQL Database pointing to the target table. In the CSV dataset configure the delimiter, encoding and whether the file has a header.

Step 3: Copy pipeline with light transformation

Create a pipeline and add a Copy activity. In the Source pane select the CSV Dataset and enable the wildcard option if you need to load multiple files (e.g.: container/folder/*.csv). In the Sink pane select the Azure SQL Dataset. For light transformation (e.g.: remove columns or convert types) use the Mapping section or add a Data Flow activity if you need more complex logic.

{
  "name": "CopyFromBlobToSql",
  "properties": {
    "activities": [
      {
        "name": "CopyCSVtoSQL",
        "type": "Copy",
        "inputs": [ { "referenceName": "CSV_Dataset", "type": "DatasetReference" } ],
        "outputs": [ { "referenceName": "SQL_Dataset", "type": "DatasetReference" } ],
        "typeProperties": {
          "source": { "type": "DelimitedTextSource" },
          "sink": { "type": "SqlSink" }
        }
      }
    ]
  }
}

Step 4: Handle errors and log failures

Add an If Condition activity or a chained error pipeline: configure the Fault tolerance property and the retry policy on the Copy activity. To capture rows with errors, configure the Copy activity to write in "fault tolerant" mode with an error column to a separate file in Blob Storage or to an audit table in Azure SQL.

Step 5: Parameterize for reuse

Parameterizing the pipeline allows using the same flow for multiple files or folders. Add parameters to the pipeline (e.g.: containerName, folderPath, tableName) and pass them to the Datasets via parameters. In the interface, in the Datasets use expressions to build the file path with @{pipeline().parameters.folderPath}.

// Example of a parameter in the dataset (expression syntax in the interface):
"path": "@concat(pipeline().parameters.containerName, '/', pipeline().parameters.folderPath)"

Verify the result

Confirm success by checking the Monitor in Azure Data Factory: see if the Copy activity completed successfully, how many rows were read and written. Check the Azure SQL table for the new records and Blob Storage for error/audit files. Also review the Copy activity Output for detailed error messages.

Conclusion

You now have a working ADF pipeline to load CSV files from Azure Blob Storage to Azure SQL with parameterization and basic error handling. Next steps: add Data Flows for complex transformations, use Mapping to match columns with types, and automate with triggers. Tip: start by testing with small files and enable detailed logging before scaling.