Hi @Jayanta Madhab Barman
You're trying to get file names inside a folder using Get Metadata inside a ForEach loop in Azure Data Factory, and attempted to use the expression:
@activity('getMetadataForEachFolder').output.childItems[??]
This error occurs because:
- The user is attempting to access an index (??) inside the childItems array, but did not provide a valid index or iterable context.
- In ADF, nested ForEach loops are not allowed, so you cannot directly iterate over files (childItems) inside an outer ForEach loop.
- Trying to simulate this by accessing an array index with childItems[??] is invalid unless you're referring to a specific number or a defined loop iterator.
Please follow this approach:
- Inside your ForEach that loops over folders, add a Get Metadata activity (getMetadataForEachFolder) to retrieve childItems (file names).
- Add a Set Variable activity (array type, e.g., fileListVar) and assign:
3.Pass fileListVar as a parameter to a child pipeline or a Data Flow, like:@activity('getMetadataForEachFolder').output.childItems
4.Inside the child pipeline, use a ForEach loop over the fileList array to process files one by one.This bypasses the nested loop limitation by offloading the second loop into a separate pipeline.folderName = @item().name fileList = @variables('fileListVar')
I hope this information helps. Please do let us know if you have 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.
As your feedback is valuable and can assist others in the community facing similar issues.
Thank you.