Hi Jon Ander,
check this microsoft doc on python imports in azure functions https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python#folder-structure they explain it well but let me break it down simpler. when u publish to azure, the root folder becomes the base for imports. so if u have a 'src' folder, python might lose its way )) move 'code.py' to the root or tweak the import like u did. but there's a cleaner way!
in 'function_app.py'
from .src.code import test
or add an empty 'init.py' inside 'src' (which u already have, good!)). sometimes python needs that to treat folders as packages. also, check if 'src' is marked as a 'source root' in your ide. this might help in other tools too. if u work with python a lot, worth looking into 'sys.path' tricks. u can dynamically add paths like this
import sys
sys.path.append('/path/to/src')
but yeah, for azure functions, keeping things in the root is the safest bet. as well check this stackoverflow thread https://stackoverflow.com/questions/10253826/path-issue-with-pytest-importerror-no-module-named-yadayadayada its a goldmine for python import quirks.
dont stress )) python imports are like a box of chocolates... u never know which one will break first :)) https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python#troubleshooting give it a peek...
hope this helps )) let me know if u need more hints
Best regards,
Alex
and "yes" if you would follow me at Q&A - personaly thx.
P.S. If my answer help to you, please Accept my answer