Running in Azure Cloud Service
This section provides instructions on how to deploy ABBYY FineReader Engine 12-based application to Azure Cloud Service. As an example, a Worker processing files by a container in Azure Storage account is represented.
To implement this scenario, an Online License that connects to *.abbyy.com license server is used.
Note: ABBYY Licensing Service can work with only one Online License at the same time.
Deploying your application to Cloud Service includes several steps:
- Organizing your Online License, local machine and cloud instance using prerequisites
- Performing the preparatory steps before deployingyour application
- Deploying your application to Cloud Service
See the code samples illustrating how to use the ABBYY FineReader Engine methods for document processing.
Prerequisites
Online License
To use an Online License, you should receive the following information from sales:
- your Сustomer Project ID
- an Online License token file
- the password to the license token file
You need to fulfill the following conditions for using an Online License wherever ABBYY Licensing Service is installed:
- Active Internet connection
- Allowed connections to *.abbyy.com on port 443 (HTTPS)
- GoDaddy root certificate for the Certification Authority (It must be installed in the local machine version of the Trusted Root Certification Authorities certificate store. See the detailed information about the certificate on the GoDaddy website).
Local machine
Before creating your Cloud 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)
- Cloud Service emulators and storage for easy debugging (see information here and download via Visual Studio Installer)
- Template solution for Azure Cloud Service (extended preview) with single Worker role project (see information here)
- .NET Framework 4.7.2
- Azure SDK (download here)
- NuGet package for working with Azure Storage and Blob containers - Azure.Storage.Blobs (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 Blob containers (see the sample below)
- Azure Storage Explorer (optional - download here)
Cloud Service instance
Cloud Service instance is for storing your WorkerRole project in Azure. Use the following specification to organize this instance:
- .NET Framework version of your Service
- PowerShell for deploying ABBYY FineReader Engine
- NuGet 2.8.5.201 or above for uploading Azure SDK
- Azure SDK for working with an Azure Storage account using PowerShell
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:
- Create two archives with the ABBYY FineReader Engine Library and Licensing Service (for example, LibraryPackage.zip and LSPackage. zip). You may create the list of files automatically, with the help of the FREngineDistribution.csv file. Use ABBYY FineReader Engine and License Server from the same package; otherwise, compatibility is not guaranteed.
- Create the Azure Storage account (frestorage in this article). All needed instructions you can find on Azure website.
- Create three Blob containers inside frestorage:
- fre-lib - for the ABBYY FineReader Engine files
- fre-input - for incoming files
- fre-output - for processing results
- Upload LibraryPackage.zip and LSPackage.zip to the fre-lib container in the most convenient way (using .NET, Powershell, Python script, or Azure Storage Explorer/Azure Portal applications).
As an example, a WorkerRole project is used for working in a configured environment. All necessary configuration files (.csdef and Cloud.cscfg) are generated automatically after creating your project.
Deploying ABBYY FineReader Engine to Cloud Service
To deploy ABBYY FineReader Engine to your new WorkerRole project:
- Specify the parameters of the Cloud.cscfg as desired.
- Specify the parameters of the .csdef file:
- (optional) your WorkerRole settings
- (optional) the size of your virtual machine
- (required) the local storage of your role (LocalStorage section - in this article, storage named LocalStorage1). Set it to 3 GB at least to ensure that the ABBYY FineReader Engine package will be deployed properly.
- (required) your role startup order (use the code samples and settings from code samples section)
- Implement your WorkerRole project to process files from the fre-input container and publish the results of processing to the fre-output container:
- the OnStart method to prepare your Cloud Service for working. This method is used to initialize the Engine and set up the TLS protocol.
- the RunAsync method to cyclically process the files taken from the fre-input container. This method detects the files in the fre-input container, processes them in memory, and places them in the fre-output container (see Processor.cs, IFileWriter.cs and Config.cs).
- the OnStop method to complete working of Cloud Service. This method is used to deinitialize the Engine.
Code Samples
This section includes code samples used to configure role startup order and ABBYY FineReader Engine settings:
- CleanUpOnStart - deletes the previous version of ABBYY FineReader Engine and simplifies its update procedure (see its listing in the CleanUpOnStart.cmd and CleanUpOnStart.ps1 files below).
- PreparePoShModules - downloads the SDK needed for Powershell to work with the Azure Storage (see its listing in the PreparePoShModules.cmd and PreparePoShModules.ps1 files below).
- PrepareLibrary - uploads and unpacks the ABBYY FineReader Engine Library from the fre-lib container to local storage (see its listing in the PrepareLibrary.cmd and PrepareLibrary.ps1 files below).
- PrepareLS - uploads, unpacks and launches the Licensing Service from the fre-lib container (see its listing in the PrepareLS.cmd and PrepareLS.ps1 files below).
It is required that the scripts listed above are run exactly in the proposed order, before launching your application. To customize the order of running the scripts, specify the following attributes:
- taskType="simple" - tasks are executed synchronously, one at a time.
- executionContext="elevated" - running a startup script with administrator rights (required to be able to install any application and running LicensingService.exe)
As a result, a folder that Cloud Service can manage will be created. This folder is used for uploading ABBYY FineReader Engine by the scrips listed above and loading the FREngine.dll for its further implementation in the sample.
CleanUpOnStart.cmd
CleanUpOnStart.ps1
PreparePoShModules.cmd
PreparePoShModules.ps1
PrepareLibrary.cmd
PrepareLibrary.ps1
PrepareLS.cmd
PrepareLS.ps1
Implementation of the IFileWriter Interface
Sample of processing the files using ABBYY FineReader Engine
Processor.cs
Config.cs
9/17/2024 3:14:40 PM