Debugging Azure Functions on Local Machine with IronOCR

Issues when running Azure locally

Common exceptions seen when encountering this issue are:

  • Error while deploying Tesseract for IronOcr
  • Failed to locate 'libtesseract-5'
  • Unable to locate 'libtesseract-5'
  • Failed to locate Tesseract-5
  • Error while locating deployment configuration file at \bin\runtimes\win-x64\native\IronOcr.Native.deployment.json
  • IronOcr: Missing .traineddata file for 'EnglishBest' which should be located at

Issue with Dependencies when Running Azure Functions locally

When running Azure locally, using Azurite (VS2022) or the Azure Storage Emulator (VS2019), an additional bin directory is created that the Storage Emulator uses for deployment. Only DLL files are copied to this directory, so software that requires additional files will not function and may throw the above exception.

You may resolve this issue by copying the runtimes directory into the separate bin directory used by the Storage Emulator. We recommend doing this as a post-build event (see below for instructions) when running locally (as recompile/build will return the bin directory to its original state). You will not encounter this issue when deploying to the cloud.

  • Problem: When running an Azure Function project locally, it creates an additional bin folder which it runs the function out of. However, it does not copy all of the necessary files into said bin folder.
  • Example: A project at C:\code\azure-functions-test that builds to C:\code\azure-functions-test\bin\Debug\netcoreapp3.1
  • Solution: Copy the C:\code\azure-functions-test\bin\Debug\netcoreapp3.1\runtimes directory so it also exists within C:\code\azure-functions-test\bin\Debug\netcoreapp3.1\bin
  • Overwrite any existing files if prompted

File V9pZPFGwDl related to Issue with Dependencies when Running Azure Functions locally

Post-Build Event Steps

  1. Right-click on the Azure Functions project, select Properties.
  2. Scroll down to the Events section.
  3. Enter a Post-build event command that will copy all required files to the correct directory:

    XCOPY "$(TargetDir)runtimes" "$(TargetDir)bin\runtimes" /S /E /Y /I /R /D
    XCOPY "$(TargetDir)runtimes" "$(TargetDir)bin\runtimes" /S /E /Y /I /R /D
    SHELL
    • Explanation:
      • XCOPY is used to copy files and directory trees.
      • $(TargetDir)runtimes is the source directory where runtime files are initially compiled.
      • $(TargetDir)bin\runtimes is the destination directory for runtime files when the application runs locally.
      • Options:
      • /S copies directories and subdirectories except empty ones.
      • /E copies all subdirectories, including empty ones.
      • /Y suppresses confirmation to overwrite existing files.
      • /I if the destination does not exist and copying more than one file, assumes that destination must be a directory.
      • /R overwrites read-only files.
      • /D copies only files that are newer or are missing from the destination.

File R3HdEFPHAL related to Post-Build Event Steps