I have a python project that works locally and has different functions split into different files based on their overall purpose. I’m trying to convert this to an Azure function v2, and I’m getting this error when I try to import my functions.
ImportError: attempted relative import with no known parent package.
I’ve tried using
from . import say_hi
With the following file structure,
/
- .functignore
- .gitignore
- function_app.py
- host.json
- local.settings.json
- requirements.txt
- test.py
And changing the file structure to
/
- .functignore
- .gitignore
- function_app.py
- host.json
- local.settings.json
- requirements.txt
/test
- __init__.py
- test.py
And then using
from .test import say_hi
and from test import say_hi
Is it possible to import functions from other files in azure functions?
test.py contains the following:
def say_hi():
print("Hi")