Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi, @prabhatnath
To format an array variable into an HTML table in Azure Data Factory or Fabric Data Pipeline and send it using Teams or Office 365 Outlook, you need to perform the following steps:
First, you need to convert the array to an HTML table string.
Second, you need to send the HTML table string via Teams or Outlook.
We need to convert the array to an HTML table. We can use an Azure Data Factory Data Flow or pipeline activities to do this.
{
"name": "Combined_Execution_Result",
"value": [
"{\"source_table_name\": \"EHS\", \"target_table_name\": \"FinalValues\", \"rows_inserted\": \"0\", \"rows_updated\": \"44\"}",
"{\"source_table_name\": \"STP\", \"target_table_name\": \"FinalValues\", \"rows_inserted\": \"0\", \"rows_updated\": \"22\"}"
]
}Add a Set Variable activity to your pipeline. In the Name field, enter the name of your new variable, e.g., FormattedHtmlTable. In the Value field, use the following expression to convert the array to an HTML table:
@concat(
'<table border="1"><tr><th>Source Table Name</th><th>Target Table Name</th><th>Rows Inserted</th><th>Rows Updated</th></tr>',
join(
array(
forEach(item in activity('YourActivityName').output.value,
concat('<tr><td>', item.source_table_name, '</td><td>', item.target_table_name, '</td><td>', item.rows_inserted, '</td><td>', item.rows_updated, '</td></tr>')
)
),
''
),
'</table>'
)Add a Web Activity to your pipeline to send a message to Teams.
In the Settings tab, configure the following:
URL: Your Teams Webhook URL.
Method: POST.
Body: Use the following JSON, replacing <FormattedHtmlTable> with the expression to get the variable's value:
{
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Pipeline Execution Results",
"weight": "Bolder",
"size": "Medium"
},
{
"type": "TextBlock",
"text": "<FormattedHtmlTable>",
"wrap": true
}
]
}
}
]
}
Best Regards,
hackcrr
If this post helps, then please consider Accept it as the solution and kudos to this post to help the other members find it more quickly
Thank you hackcrr for your help.
I am getting below error when I am using the HTML fomatting expression inside the Set Variable activity.
Unrecognized expression: item in activity('CombineResults').output.value
Not able to figureout what could be the issue. Please suggest.
The previous activity was also a Set Variable (CombineResults) which is producing the JSON output to the Combined_Execution_Result variable of Array type. So I think the Array variable Combined_Execution_Result has the JSON.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
| User | Count |
|---|---|
| 11 | |
| 10 | |
| 9 | |
| 8 | |
| 8 |