An Azure service for ingesting, preparing, and transforming data at scale.
Yes, this scenario is possible within Azure Data Factory's Copy Activity, with a bit of JSON mapping and transformation. Since you want to insert both the id and the entire comment object into your SQL table, here's how you can achieve that:
Set Collection Reference: You've already done this correctly:
$.comments
Create a Mapping in Copy Activity: Under Mappings, map:
-
id→id - Use Expression mapping to convert the full comment object to a JSON string for
json_object.
Use Expression Mapping for json_object: Unfortunately, ADF doesn't have a built-in way to directly map the whole object as a JSON string. But you can work around this using a Derived Column transformation (if using Data Flow), or use a custom inline mapping with ADF's Copy Activity if you're using Mapping Data Flows.
Option A: Use Data Flow
Add a Derived Column step before the sink.
Create a new column json_object using the toString() or string() function:
json_object = toString($$)
Here, $$ refers to the current object, so it serializes the whole comment.
Option B: Preprocess in Azure Function / Logic App (if needed)
If you're limited to just Copy Activity (without Data Flows), then you'd need to preprocess the source in:
- Azure Function
- Logic App
- or REST API that returns
json_objectas a string field per record.
Alternative: Use Copy Activity with REST + Sink Stored Procedure
If using only Copy Activity, you can write a Stored Procedure as your Sink and pass:
-
idas one column - the full JSON row as a string using
@activity('YourCopyActivity').output.rowsor a similar workaround.
Hope this helps. If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.