Hi @Glasier
Thanks for the question and using MS Q&A platform.
ASAIK there is no direct way to create key-value pairs using the pipeline expression builder in ADF, like you can in dataflows. Here is a method to build the required key-value pairs in ADF pipelines:
I have used 2 parameters with these values:
Let's say req
is the variable where we want to store our final key-value pairs. I have initialized it with an empty object {}
.
In the 'ForEach' activity, I set the items value to @range(0, length(pipeline().parameters.keys))
to generate the index.
Now, I have taken a variable called temp
to apply union on the current value of req
and the dynamically built key-value pair for current iteration.
@string(union(json(variables('req')),json(concat('{"',pipeline().parameters.keys[item()],'":"',pipeline().parameters.values[item()],'"}'))))
Finally, I update the req
variable in each iteration with the current temp
value, i.e., @variables('temp')
.
After running the pipeline, it will generate the following output in the req variable:
ADF pipelines do not support variables of the object type. If you need to use an object stored as a string, you can convert it to an object using the @json() function.
Hope this helps. Do let us know if you any further queries.
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.