Interpreting Script activity output json with Azure Data Factory\Synapse analytics
Script activity in Azure Data Factory\ Synapse analytics is very helpful to run queries against data sources mentioned here in this document.
When we use two or more queries in the script activity, it is important to understand the output json of script activity to write expressions based on the output in the subsequent activities.
Consider the below Pipeline design:
We have two select queries as follows in script activity, and each of which will give a resultSet.
select top 2 * from tbl_adf;
Select * from tbladf
When debugged, it will give output as below.
So, as per line #2, resultSet count =2. It is because, we have two select queries in the script activity.
In case we want to get the Total Revenue value from Row#1, we have to write below expression.
@activity('Script1_copy1').output.resultSets[0].rows[0]['Total Revenue']
where, resultSets[0]: First select query result
rows[0]: first row in resultSets[0]
Same way, if we want to get the Total Revenue value from Row#2, we have to write below expression.
@activity('Script1_copy1').output.resultSets[0].rows[1]['Total Revenue']
where, resultSets[0]: First select query result
rows[1]: second row in resultSets[0]
And, the below expression gets the rowcount from each resultset.
@activity('Script1_copy1').output.resultSets[0].RowCount
@activity('Script1_copy1').output.resultSets[1].RowCount
So, by understanding the structure of output json, we are able to write expressions to access individual elements of the output of any activity in ADF\Synapse.
Published on:
Learn moreRelated posts
Primer: Output Data Generated with an Azure Automation Runbook to a SharePoint List
The second part of the Azure Automation runbook primer brings us to output, specifically how to create items generated by a runbook in a Share...
Databricks vs Azure Synapse Analytics: A Comprehensive Comparison for Modern Data Solutions
Table of Contents Introduction Data is at the core of modern business decision-making. As companies increasingly rely on data-driven insights,...
Primer: How to Use Azure Automation to Run Microsoft Graph PowerShell SDK Scripts
A reader asked why it seems so difficult to use Azure Automation runbooks to process Microsoft 365 data. In fact, it's not so hard, and here's...
Extending Regular Expressions (Regex) Support on Azure SQL Managed Instance (MI)
We are happy to announce the Private Preview of Regular Expressions (Regex) support on Azure SQL Managed Instance (MI). This new feature bring...
Shield your Copilot with Azure AI
Azure Confidential Clean Rooms demonstration
Final Days for the MSOnline and AzureAD PowerShell Modules
After many twists and turns since August 2021, the MSOnline module retirement will happen in April 2025. The AzureAD module will then retire i...
Join the Conversation: Call for Proposals for Azure Cosmos DB Conf 2025!
Are you passionate about Azure Cosmos DB? Do you have insights, experiences, or innovations that the developer community would love to hear? N...