Chinese Simplified (简体中文)

Running in Azure App Service

This section provides instructions on how to deploy ABBYY FineReader Engine 12-based application to Azure App Service. As an example, a pair of WebJob projects that use data from Azure Storage account is represented. Files processing is performed using a Blob container.
Using this scenario, you will obtain the best recognition results for small one-page documents, such as invoices, receipts, etc.

Deploying your application to App Service includes several steps:

  1. Organizing your local machine and app instance using prerequisites
  2. Performing the preparatory steps before deploying your application
  3. Deploying and running your application in App Service

Use the code samples represented in instruction below.

Prerequisites

Local machine

Before creating your App Service, use the following specification to organize your local machine:

  • Visual Studio 2019 and its modules for developing applications for Azure (check Azure feature in Visual Studio or use Visual Studio Installer to download such modules)
  • Azure SDK (download here)
  • .NET Framework 4.7.2
  • NuGet Package for working with Azure Storage and Blob containers:
    • Azure.Storage.Blobs (download here)
    • Azure.Storage.Queues (download here)
    • Newtonsoft.Json (download here)
    • System.IO.Compression.ZipFile (download here)
  • ABBYY FineReader Engine wrapper for .Net Framework 4.7 (in the C:\ProgramData\ABBYY\SDK\12\FineReader Engine\Inc\.NET interops folder after developer installation)
  • IFileWriter interface overridden for working with the Blob containers (see the sample below)
  • Azure Storage Explorer (optional - download here)
  • Virtual machine in your Azure account intended for the licensing procedures. For the further configuration, you need:
    • IP-address
    • Open connection port (default or user-defined). To open it, use a firewall
    • Sockets network protocol connection details

Preparatory steps

Preparatory steps are to be done on your local machine. By completing these steps, you will prepare all necessary settings and files to start deploying your application:

  1. Create an archive with the ABBYY FineReader Engine Library (for example, LibraryPackage.zip). List of files represents in the FREngineDistribution.csv file.
    Important! If you have limited storage space (for example, you use an App Service Plan with 1GB space), we recommend using the /extract option to create your custom ABBYY FineReader Engine package with minimal size. The rest of the storage space will be used for processing the files.
    When creating an archive, take into account the ABBYY FineReader Engine licensing settings must be set up according to the virtual machine settings:
    • The LicensingSettings.xml file must be set up for the Network configuration (see Working with the LicensingSettings.xml File).
    • The Sockets network protocol must be used.
    • Online License token file must be located in Bin64 folder.
  2. Create an Azure Storage account (frestorage in this article). All needed instructions you can find on Azure website.
  3. Create your App Service as desired (see instructions here).
  4. Create two Blob containers inside frestorage:
    • fre-lib - for the ABBYY FineReader Engine files
    • processing-container - for processing results
  5. Upload LibraryPackage.zip to the fre-lib container in the most convenient way (using .NET, Powershell, Python script or Azure Storage Explorer/Azure Portal applications).
  6. Deploy and configure the virtual machine with the licensing settings in your Azure account:
    • Install the License Manager utility via installLM.exe from the LibraryPackage.zip.
    • Set up the Sockets network protocol in the LicensingSettings.xml, and then restart the Licensing Service.
    • Ensure that Azure App Service can access the Licensing Service connection port (adjust the Windows Firewall rules on virtual machine).
    • Activate your license (for software protection only; online protection does not require activation).
  7. Create two queues inside frestorage:
    • processing-queue - for setting the tasks of files processing
    • status-queue - for notifying about task completion
  8. Create two Azure WebJob (.NET Framework) projects in Visual Studio 2019 to work with frestorage:
    • FreDeployerJob - for deploying LibraryPackage.zip to App Service (see listing of its files: Config.cs, Functions.cs, Program.cs below)
    • FreProcessorJob - for document processing (see listing of its files: Config.cs, Functions.cs, Program.cs, EngineLoader.cs, IFileWriter.cs, Processor.cs below)

Deploying and running ABBYY FineReader Engine in App Service

To deploy ABBYY FineReader Engine:

  1. Publish FreDeployerJob to Azure App Service using Visual Studio (set Triggered for WebJob Type).
  2. Open your App Service in the Azure portal.
  3. Open WebJobs of your App Service.
  4. Find FreDeployerJob in the list of WebJobs.
  5. Launch FreDeployerJob by the right-clicking+Run command on the WebJobs tab.

You may access the Logs tab to check the result of deployment. If it succeeds, LibraryPackage.zip is uploaded from the fre-lib container and deployed inside the %HOME_EXPANDED% folder available for all entities in App Service.

To deploy FreProcessorJob, publish FreProcessorJob to Azure App Service using Visual Studio (set Continuous for WebJob Type). As a result, FreProcessorJob will be in the list of WebJobs tabs of your App Service.

To process a file:

  1. Upload the file you intend to process to the processing-container.
  2. Add a JSON message for a new task of processing in format {"blob-item-name" : "file_name"} to the processing-queue. If you upload Demo.tif to the processing-container, your message should be:
{"blob-item-name" : "Demo.tif"}
    
  1. Wait for the task to complete. As soon as the new task is set, FreProcessorJob starts to process the specified file in memory. The status-queue will contain entries about the execution of this task.
  2. Find the output file in the processing-container.

Important!
1. FreProcessorJob operates as a single-threaded process. If you intend to process your files in parallel, you need to create several FreProcessorJob that will be listening to the same queue.
2. Every additional FreProcessorJob consumes extra memory. Take into account this fact when buying your Service Plan. For example, in Azure Free Service Plan is nice to have only one FreProcessorJob that consumes a little memory and thus ensures the stability of file processing.
3. Using single FreProcessorJob is not suitable for processing large multi-page documents. In this case, consider recognition of your document in Azure Cloud Service or Azure Virtual Machine instead of App Service.

Code Samples

This section includes code samples used to deploy and implement the ABBYY FineReader Engine API in App Service.

FreDeployerJob:

Config.cs

Functions.cs

Program.cs

FreProcessorJob:

Config.cs

Functions.cs

Program.cs

EngineLoader.cs

IFileWriter.cs

Processor.cs

9/17/2024 3:14:41 PM

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.