This example hosts ediFabric Native behind an Azure Functions HTTP API. It translates X12 EDI to JSON and back, validates transaction sets, and generates acknowledgments using the C# bindings from edifabric-csharp-bindings.
The native library is a self-contained shared library. No EdiFabric.Api NuGet package (aka EdiNation InHouse) is required on the target machine beyond this isolated-process Azure Functions host.
The example is for .NET isolated process function.
ediFabric Native API for Azure Functions on GitHub
Prerequisites
- Visual Studio or the .NET 10 SDK.
- If you don't have an Azure subscription, create an Azure free account before you begin.
- Download Postman - it's an application to consume/test your API.
- The native library for your platform:
| Platform | File |
|---|---|
| Windows | edifabric-x12-tools.dll |
| Linux | edifabric-x12-tools.so |
| macOS | edifabric-x12-tools.dylib |
Download ediFabric Native Library
Put the library in the repository root or in EdiFabric.Api.Azure, or set Configuration.LibraryPath / EDIFABRIC_X12_LIB. The project copies it next to the worker on build and publish when it is found in those folders.
Linux Azure Function Apps cannot load the Windows .dll. Before publishing to Linux, place edifabric-x12-tools.so (glibc x64) in the project or repository root so it is included in the deployment package. Windows Function Apps need edifabric-x12-tools.dll instead.
License
Set Configuration.ApiKey to your serial. The free-plan serial is:
bd96a836feca45cb91c86ee65d281f52
The free plan authorizes with set_serial only. Tokens (BlobCache) are available for the Enterprise license.
Setup
Rebuild the solution. If there are any build errors, contact us at https://support.edifabric.com/hc/en-us/requests/new for assistance.
The C# bindings live in EdiFabric.Api.Azure/Native (NativeMethods.cs and EdiFabricX12.cs), copied from the edifabric-csharp-bindings repository.
By default the API uses the online spec service (SetMap with "default": "<serial>"). To use local JSON models instead, place a map/map.json next to the function project (see the bindings README for the map format).
Create an Azure Function in the Azure portal
Azure Functions lets you run your code in a serverless environment.
Detailed tutorial on how to create an Azure Function. For this tutorial, we created an Azure Function named "edinationtest".
Select to Publish as Code, Runtime stack .NET, and Version 10:
Then, use the default suggestions for the other tabs, and finally, Create the function.
Publish the Function from Visual Studio
- Open solution EdiFabric.Api.Azure.sln in Visual Studio.
-
Open file Configuration.cs and change ApiKey to your paid key or leave it to use the free key.
- Rebuild the solution and ensure all package dependencies were installed correctly.
- Right-click on the project name and select "Publish".
- Publish it to the Azure Function you created in the first step.
Test the Function
-
In the Azure portal, go to your function's overview tab, and copy the function URL:
- Download and open Postman. Let's test the X12 read operation first.
-
Open a new tab in Postman, select the POST method, and add the following request URL (full API reference):
{Your function URL}/api/x12/read -
Go to the Body tab, select the "binary" content, and browse your text X12/HIPAA file.
If you don't have a test file, use one of ours - X12 HIPAA, X12.
-
Finally, hit the Send button and inspect the response body:
Cache tokens
By default ediFabric Native would request a token from the Authentication API every time. To avoid these calls altogether and work in a fully offline mode, implement a token cache.
Tokens are only available for the Enterprise plan
To implement the token cache, open the file EdiFunctions.cs and follow the instructions in the comments:
Cache models
By default ediFabric Native would request a new JSON model from the Authentication API every time a new transaction needs to be parsed. To avoid these calls altogether and work in a fully offline mode, create a model map.
SetMap tells the engine where to find transaction-set models. Keys are message:version. Set default to your serial to resolve unmapped transaction sets through the online spec service, or leave it null and map everything locally.
{
"default": null,
"maps": {
"837:005010X222A1": { "type": 1, "name": "837P.json", "location": "/opt/models" },
"850:005010": { "type": 1, "name": "850.json", "location": "/opt/models" }
}
}
All X12 transactions, such as 837P, 834, 850, etc. are represented as proprietary JSON. Download a standard model from EdiNation Spec Library, or a custom model from EdiNation Spec Builder. Create/modify models in OpenEDI format, upload them in EdiNation Spec Builder and download them as JSON for use in ediFabric Native.
To download a model in either EdiNation Spec Library or EdiNation Spec Builder, select the model first, then in the JSON view select the Download button in the top right corner.
Choose to download as ediFabric Native. Models are JSON files, and must be included, together with the map, in the deployment package.

Comments
0 comments
Please sign in to leave a comment.