Azure Cognitive and Business Central : “Form Recognizer” API integration

Easily track employee expenses (Part 1 – training).

How to get the receipt grand total from an image by using Azure Cognitive API and save it Business Central.


  • The user, by using a mobile device, takes the photo of the receipt and uploads to an azure blob storage;
  • The Azure “Form Recognizer” API service automatically recognise the receipt grand total;
  • Business Central automatically fills the employee expense grand total;


  • A blog storage to store images.
  • An Azure Form Recognizer account.
  • A docker image to train a custom model.
  • A custom Business Central AL codeunit


Azure cognitive services offers a variety of APIs:

Among all the available features, “Form Recognizer” allows to detect part of a receipt.

At the moment “Form Recognizer”, just out of beta stage, only applies to UK/USA receipts and isn’t yet able to correctly detect grand totals with EU receipts.

This means it’s necessary to train a custom model to get better results.

To create the service is as easy as three mouse clicks: Add Resource, select “Form Recognizer” from list, configure names and location/resource group.

Once the service has been created, under Keys and Endpoints you can find “Key 1” and “Endpoint”, these two strings will be used when configuring Label Tools.


I create a blob container on Azure Portal and I upload there all of my receipts by using “Storage Explorer”.

It’s important to enable “Configure cross-domain resource sharing (CORS)” access.


Since the service by default recognises only US/UK receipts I have to create my own custom model.

To create a custom model I followed official microsoft instructions

I installed docker, and switched to Linux containers (unfortunately the label tools requires a linux container instead of a Windows container).

Just with two lines are enough to have the container up and running:

First I pull the label tool container:

docker pull 

Then I start the container:

docker run -it -p 3000:80 eula=accept

It’s now possibile to open the web console from local browser:


First of all I configured connection with the blob storage, then I configured the form recognizer endpoint and API key from previous chapter.

The web application imports all of the images from blob storage.

I create my own tag as a numeric.

Now the boring part, for each of the image I manually assign the tag to the corresponding text on receipt.

Now it’s time to start the training.

After a couple of minutes I get the result of training session:

The web console allows to test the custom model on receipts by uploading them.


In next article I will cover how to call the Cognitive API from a Business Central codeunit.


21st of July, 2020

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