Using Inline code in Logic Apps. Could it replace function app?

The requirement is simple; read daily generated xls files, process, write to DB. Sometimes more than one file generated and needs to be sorted regarding the data based on the timeline.

Using Degree of Parallelism speeds up completion time. But absolutely messes up the sort order. Also if you need time to process time and using delay option, concurrency omits delay and executes other branch. Unfortunately, there isn’t any option to arrange needs. So disabling concurrency may help if your files are already sorted.

Unfortunately, there is no ready to use a sorting function. At this point inline code option saves us. Thanks to Yustin Yoo, I figure out the code. You can find out more the links below:

Basically I list files in the folder, sort them and process them. Output of “List files” is array mode therefore the output of “Sort files” is in array mode as well. I run the Logic app and get the JSON sample from “List files” component output. I have a little trick in the end: to get the output as JSON format, I’ve added “return {“files”: sorted };”

"use strict";
var items = workflowContext.actions.List_Files.outputs.body.value;
var sorted = items.sort(function (a, b) {
  var nameA = a.Name;
  var nameB = b.Name;
  if (nameA < nameB) {
    return -1;
  if (nameA > nameB) {
    return 1;
  return 0;
return {"files": sorted };

May be If worked more on this inline code, the function app requirement could be replaced. Obviously, more progress needed on component and code editor 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *