Azure Function App

This example shows the basics deployment of an Azure Function App using ETLBox as dependency.

In this example we will deploy a simple azure function. The function will receive some json file that contains an array with data, and it will store this data locally as a csv file and return the csv file data as response.

This issue is already reported in different github issues (e.g. here   ).


This example was created using Visual Studio (latest version). Visual Studio offers emulators for Function Apps. If you are going to deploy this function to Azure, you will need a valid Azure subscription.

Create a azure function project

You can create the function app using a template project or manually. At then end, you should end up with a project file that looks similar to this:

<Project Sdk="Microsoft.NET.Sdk">
    <PackageReference Include="ETLBox" Version="2.4.1" />
    <PackageReference Include="ETLBox.Csv" Version="2.4.1" />
    <PackageReference Include="ETLBox.Json" Version="2.4.1" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
    <None Update="host.json">
    <None Update="local.settings.json">

This project file will already include the ETLBox, ETLBox.Csv and ETLBox.Json packages.

Please note that you need to manually add <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> to the project file.

Alernatively, you can downgrade the package for the Functiosn Sdk: <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />

Creating the function

Add a class “DemoFunction.cs” to your project:

namespace AzureFunctionApp
    public static class DemoFunction
        public static async Task<HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            ILogger log)
            log.LogInformation("Received a json file to transform.");

            string filename = Guid.NewGuid().ToString() + ".csv";

            log.LogInformation("Temp file used to hold data: " + filename);

            var jsonSource = new JsonSource() {
                CreateStreamReader = _ => new StreamReader(req.Body)
            var csvFileDest = new CsvDestination(filename);

            await Network.ExecuteAsync(jsonSource);

            log.LogInformation("Successfully stored data in file - now returning the content as response.");

            return new HttpResponseMessage() {
                StatusCode = HttpStatusCode.OK,
                Content = new StreamContent(new FileStream(filename, FileMode.Open))

Testing the function

You can execute your function, either in your test environment or by deploying it to Azure. Now you can send a POST request to your newly created endpoint:

E.g. if you send the following POST body to your endpoint

		"Id" : 1,
		"Value" : "A"
		"Id" : 2,
		"Value" : "B"

the function will receive this json, and create a file which is named like 217bef6f-a75e-4e98-b1cc-f05bd8a20f5d.csv in the local function folder. Then it will return the content of the file as response:


Code on Github

The whole code for this example is available on GitHub