Manipulating Data with Azure Function Apps

Quite often before D365 can process our inbound message, we need to manipulate it. This might be changing the structure of the data or changing values. As with most things, there is more than one way to skin a cat, but you could make a strong argument that the best way to approach this  would be to use the Azure Enterprise Integration Pack along with XML and  / or flat file schemas.

In smaller & simpler scenarios, this could be overkill. The Enterprise Integration adds a lot of nice capabilities, but also adds complexity and the extra $1,000 per month can be a hard sell.

A simpler approach could be to utilize an Azure Function App, called from a Logic App. A Function App is essentially a serverless compute service, written in JavaScript, C# or F#, that can run a piece of code on demand, and scale out as needed.  Pricing is considerably more attractive than an Enterprise Account, if you do not need all of those features.

In this quick example, we’re receiving data from a trading partner, and need to manipulate it before passing it on to D365 via our REST API.

First, create a new Function App –1


Then create a new function using a template, or from blank –


HttpTrigger C# Template –


This simple example expects to receive a key value parameter, of eg name=Rob, and returns the string “Hello Rob” if passed correctly.

Here’s our modified code. Say we want to remove all lines that do not start with ‘0’. Our inbound message is one long string. We can convert that to an array, and use the filter method to obtain a subset of lines that start with ‘0’. Lastly, we convert the array back to a string, and return it to our Logic App.

#r “Newtonsoft.Json”

using System.Net;

using Newtonsoft.Json;

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)


string jsonContent = await req.Content.ReadAsStringAsync();

dynamic data = JsonConvert.DeserializeObject(jsonContent);

string dataString = data.body;

string[] lines = dataString.Split(‘\n’);

lines = Array.FindAll(lines, s => s.StartsWith(“0”));

return req.CreateResponse(HttpStatusCode.OK, String.Join(“\n”, lines));


The function returns the modified data back to our Logic App, which can then pass it on to D365.

To call the Function App from the Logic App, add a Azure Function action, and select the Function you created,



The input to the action should be the contents of the file. The output of the action will be the output of the function – the filtered message body.


References –

Azure Function App Documentation

Call a function from Flow

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s