-
Notifications
You must be signed in to change notification settings - Fork 107
Closed
Milestone
Description
Hack required to import Shared Code modules into Python functions
Investigative information
Repro steps
- Create a folder
SharedCodeadjacent to your function folders - Added a python module into the
SharedCodefolder - Attempt to import your
SharedCodemodules into existing Python Azure Function - Run your Python Azure Function
Expected behavior
Module should be available by default because it is inside the same virtual environment without requiring any PYTHONPATH mods.
Actual behavior
Error:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.HttpTriggerPython ---> Microsoft.Azure.WebJobs.Script.Rpc.RpcException: Result: Failure
Exception: ModuleNotFoundError: No module named 'SharedCode'
Known workarounds
Add the following lines to the top of your __init__.py in your Azure Function. This will allow any modules defined in your FunctionApp to be available for import
import sys
import os
sys.path.append(os.path.abspath(""))
ericson-cepeda and Bhanu-py
Metadata
Metadata
Assignees
Labels
No labels