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.
Note
Microsoft.NET.Sdk.Functions versions 3.0.4
and above, a new feature was introduced that cleans the compiled output from unnecessary dlls in order to trim down the assemblies. This feature cleans the output too aggressively and will result in exceptions when referencing and using ETLBox packages. You need to either downgrade to Microsoft.NET.Sdk.Functions 3.0.3
or to add <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
to your project fileThis issue is already reported in different github issues (e.g. here ).
Preqrequisites
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:
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:
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
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: