@Suganya Sivashanmugam You could use the inline code action to do this in a couple of lines compared to having an Azure Function for this.
Here is code that you could use
var data = workflowContext.actions.Compose.outputs;
var rows = data.split('\n').map(a => a.split(','));
var keys = rows.shift();
var json = [];
for (let row of rows) {
let o = {};
for (let i = 0; i < row.length; i++) {
o[keys[i]] = row[i];
}
json.push(o);
}
return json;
and here is the Workflow JSON for reference.
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "id,name,rank\n1,Alex,1\n2,Bob,2\n3,Charlie,3",
"runAfter": {},
"type": "Compose"
},
"Execute_JavaScript_Code": {
"inputs": {
"code": "var data = workflowContext.actions.Compose.outputs;\r\nvar rows = data.split('\\n').map(a => a.split(','));\r\n\r\nvar keys = rows.shift();\r\nvar json = [];\r\n\r\nfor (let row of rows) {\r\n let o = {};\r\n for (let i = 0; i < row.length; i++) {\r\n o[keys[i]] = row[i];\r\n }\r\n json.push(o);\r\n}\r\n\r\nreturn json;"
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "JavaScriptCode"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"triggers": {
"manual": {
"inputs": {},
"kind": "Http",
"type": "Request"
}
}
},
"kind": "Stateless"
}