Hi @N2120 , Thankyou for using Microsoft Q&A platform and thanks for posting your query here. As I understand your ask , you are trying to fetch the firstrow json out of the lookup activity and store it in the .txt file using python script via custom activity in ADF. Please let me know if that is not the ask here. To repro your case, I created a pool under the batch account . Also, stored the below python script in my storage account which is supposed to read the input argument and store the same in output.txt file in document form:
from sys import argv
print(argv[1])
output=argv[1]
outdic={}
outdic["firstrow"]=output
# Write output text to file
with open('output.txt', 'w') as f:
f.write(str(outdic))
- Use look up activity to read the sql table data.
- Use Foreach activity to iterate through the lookup output, since you need only firstrow in the output file, you can use below expression in foreach , or you can directly use custom activity .
@array(activity('Lookup1').output.value[0])
3.Use custom activity inside foreach, and use this expression in command :
@concat('python firstrow.py ', item())
Below are the videos of implementation:
You can see the output.txt file in the batch account job under the root folder .
For more details on creation of batch account and pool, you can go through the following videos: Azure Data Factory - Execute Python script from ADF Azure Data Factory - Access Custom Activity Output from subsequent activities in ADF
Hope it helps. Kindly accept the answer as accepted answer helps community. Thankyou