问题
I have an simple python module AdditionalLibrary, I do not want to publish it nowhere public. I have also an azure python serverless function app ExamplePythonServerlessFunction I want to publish on azure.
I followed official documentation:
- https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-python
- https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python
and an out-dated page https://prmadi.com/install-python-modules-on-azure-app-services/
Finally I have a wheelhouse
directory in my azure function project containing *.whl
files for every dependency I need. I try to put additional flags to my requirments.txt
file to use wheelhouse
directory instead of index. This is content of my requirments.txt
file.
--no-index --find-links file://wheelhouse
Additional-Library==1.0
azure-functions==1.0.0b4
azure-functions-worker==1.0.0b6
grpcio==1.20.1
grpcio-tools==1.20.1
protobuf==3.6.1
six==1.11.0
During publishing the app:
$ func azure functionapp publish ${APP_NAME} --build-native-deps
I get an error:
Url 'file://wheelhouse' is ignored: it is neither a file nor a directory.
and I am not able to install dependencies. Is that way is correct? How can I install some additional dependencies to azure function app.
Any help and advice will be appreciated.
回答1:
I've been doing this:
import os
import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname( __file__ ), '../../../az/Lib/site-packages')))
from azure.storage.cloudstorageaccount import CloudStorageAccount,AccountPermissions,Services,ResourceTypes
from azure.storage.blob import BlockBlobService
so you can just create a directory in your function and add it to path and import modules from that path.
来源:https://stackoverflow.com/questions/56011364/not-able-to-publish-azure-python-function-app-with-external-dependencies-not-in