Debugging Azure Functions Project on Local Machine
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 in to 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
Post-Build Event:
- Right-click on the Azure Functions project, select Properties
- Scroll down to the Events section
- Enter a Post-build event of
XCOPY "$(TargetDir)runtimes" "$(TargetDir)bin/runtimes" /S /E /Y /I /R /D