An Azure service for ingesting, preparing, and transforming data at scale.
For the pipeline, use a Lookup Activity first to retrieve the identifiers and file names rather than retrieving the potentially large binary payload. For example, the Lookup can execute SELECT Id, FileName FROM ImagesTable. The Lookup output then becomes the input to a ForEach Activity using @activity('LookupActivityName').output.value. Set Sequential to False if the database and ADF integration runtime can support parallel processing.
Inside the ForEach, use a Copy Activity with a parameterized source query such as
SELECT ImageColumn FROM ImagesTable WHERE Id = @{item().Id}
The source should return the actual binary/BLOB column, not a Base64 or hexadecimal representation. Configure the Azure Blob Storage sink as Binary format and use the current item's file name, such as @item().FileName, for the destination file name. This results in one Blob per database row, with the Blob containing the original binary image bytes.
For example, the overall flow is:
Lookup → ForEach → Copy Activity
The Lookup returns something like:
SELECT Id, FileName FROM ImagesTable
The Copy Activity inside the ForEach retrieves the actual image:
SELECT ImageColumn FROM ImagesTable WHERE Id = @{item().Id}
The Blob destination then uses a dynamic file name such as:
@item().FileName
Casting an image/BLOB column to VARBINARY does not by itself solve the problem. If ADF subsequently serializes the relational result into a tabular format, the resulting file is not the original image binary. The Copy Activity should preserve the source column as binary and the Blob sink must write it as Binary. For cases where the ADF Copy Activity cannot correctly materialize the database BLOB as the required individual binary file, an Azure Function is a suitable alternative - the Function can retrieve the BLOB directly from Oracle or SQL Server and write the exact byte stream to Blob Storage.
For very large numbers of images, I would also consider avoiding one Lookup/ForEach iteration per image because it creates a database query and Copy Activity execution for every row. In that situation, batching or an Azure Function-based approach can be more efficient.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin