How can I import modules for a Python Azure Function?
import requests
Leads to:
2016-08-16T01:02:02.317 Exception while executing function: Functions.detect_measure. Microsoft.Azure.WebJobs.Script: Traceback (most recent call last):
File "D:\home\site\wwwroot\detect_measure\run.py", line 1, in <module>
import requests
ImportError: No module named requests
Related, where are the modules available documented?
Related question with fully documented answer Python libraries on Web Job
Although you can develop your Python-based functions locally on Windows, Python functions are supported in Azure only when they're running on Linux.
Bring in dependencies from the project directoryBy putting the dependencies in a folder inside functions app project directory, the dependencies folder will get deployed together with the code. As a result, your function code can access the dependencies in the cloud via file system api.
You need to include a requirements.txt file with your code which lists all the python dependencies of your function
From the docs: https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python#python-version-and-package-management
For example, your reqirements.txt file would contain:
requests==2.19.1
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