I have a table with 120,000 records in it. This will be my source table.
For each record in the table, I want to send a request to a REST API and then make a stored procedure call. There are reasons this has to be done and one by one of which I don't want to elaborate here.
I know I can do this with a Lookup Activity that will look up the table (to a max of 5,000) items and then I can do a For Each on this array and for each iteration of the For Each I use a Web Activity to make the REST API request. And then call the stored procedure activity.
However, to do this, I need to add a bunch of paging variables (skip, etc) to the stored procedure or query. Then I have to have a nested For Each (the first ForEach does the paging and the lookup activity is inside it.. the second For Each iterates each record within the page set). But, you can't nest a For Each inside another ForEach, so I have to create another pipeline and execute that from within the foreach to do it's own foreach and pass in the array to that pipeline.
Is this convoluted way of doing this really the only way?
This is for a very simple process of doing the following: For each record { Call Rest API }
As lookup has the limitation of 5000 rows, You need to Design a two-level pipeline where the outer pipeline iterates over an inner pipeline, which retrieves data that doesn't exceed the maximum rows or size. As per document.
So, the possible solution would be, paginate with lookup query with variables then pass this output to another pipelines parameter to iterate on it and call the rest API and Stored procedure respectively.
To paginate the query, you can follow below format.
@string(0) - 0as below:@equals('120000', variables('counter'))variables('counter')@string(add(int(variables('tempCounter')),5000))it will add 5000 to initial value.