I have created an image processing script in Python
(with dlib
and OpenCV
) - I was wondering how I can bring this functionality to Azure Functions, so that the script can be called via an API. As Python
is still in preview for Azure Functions
I wanted to know if anybody here has experience with bringing modules to Azure Functions
and if it's possible to install OpenCV
there?
You can bring your own modules to your Function by uploading them into the a lib
folder residing in the same folder as your Function.
However, in the context of OpenCV, it is not a supported scenario at the moment. The default Python version being used in the Azure Function environment is Python 2.7. If you try to execute a Function code using OpenCV for Python 2.7, the error message you will get would be similar to the following,
2016-11-07T20:47:33.151 Function completed (Failure, Id=42fa9d38-05f1-46d4-a8ce-9fbaa24a870d)
2016-11-07T20:47:33.166 Exception while executing function: Functions.ImageProcessor. Microsoft.Azure.WebJobs.Script: ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "D:\home\site\wwwroot\ImageProcessor\run.py", line 17, in <module>
import cv2
ImportError: numpy.core.multiarray failed to import
The fix for this is to update the numpy
version used by Python 2.7
, but you will not be able to run the update yourself.
As you have noted, Python language support for Azure Functions is in an experimental stage right now. These issues will be addressed when Python is fully on-boarded as a first-class language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With