Append string values generated per iteration without append variable or array variable.

Rahi Jangle 20 Reputation points
2024-03-01T06:48:52.5+00:00

I have ADF pipeline Which have parameter set multiple comma separated values to it. I have for each loop which iterates over these parameter values and set variable activity inside for each loop using String type variable named "dynamicbody" which generates different string values per iteration accepting different parameter value each time.

Next I need to append these iteration outputs of first set variable activity for which I used append variable activity which uses array type of variable to append values. Now the thing is we use terraform to deploy ADF pipelines and array variable is not supported in terraform to deploy.

So, I want to append these string values generated by first set variable activity per iteration without using append variable activity and without using array type variable. How to achieve this? Can we use another set variable activity to append values using string type variable?(I tried same but not succeeded). Any other way to do this?

Please help if anyone knowshow to achieve the same.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,623 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Harishga 6,000 Reputation points Microsoft External Staff
    2024-03-04T04:29:34.6233333+00:00

    Hi @Rahi Jangle

    Welcome to Microsoft Q&A platform and thanks for posting your question here.

    Based on your query, it seems like you want to append the string values generated by the first Set Variable activity per iteration without using the Append Variable activity and without using an array type variable. 

    One way to achieve this is by using a String type variable and concatenating the string values generated by the Set Variable activity in each iteration.

    Here's an example of how you can achieve this:

    • Create a String type variable, let's call it "outputString".
    • Inside the For Each loop, set the value of the "dynamicbody" variable to a new variable, let's call it "iterationOutput".
    •  Concatenate the "iterationOutput" variable with the "outputString" variable using the expression language in the Set Variable activity. The expression should look like this: @concat(variables('outputString'), variables('iterationOutput')).
    •  At the end of the For Each loop, the "outputString" variable will contain the concatenated string values generated by the Set Variable activity in each iteration.

    This approach may not be as efficient as using the Append Variable activity with an array type variable, especially if you have a large number of iterations. However, it should work as a workaround if you cannot use the Append Variable activity or an array type variable. 

    Reference
    https://learn.microsoft.com/en-us/azure/data-factory/control-flow-set-variable-activity
    https://learn.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions
    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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.