Getting started with azure function app and the deployment can be somewhat challenging. I really struggled with the module not found error.
Error itself
Result: Failure Exception: ImportError: cannot import name 'refresh workspace' from 'refresh.refresh workspace'
(home/site/wwwroot/function-app/module/module_script.py) Please check the requirements txt file for the missing module For more info
please reter the troubleshootina auide: httos://aka.ms/functions-modulenotfound Stack: File "/azure-functions
host/workers/ovthon/3.9/LINUX/X64/azure functions worker/dispatcher.ov" line 365. in handle function load reguest func = loader.load function( File
"/azure_functions_hoc
9/LINUX/X64/azure functions worker/utils/wrappers.ov" line 48. in call raise extend exception message(e, message)
File "/azure-functions-host/workers/pvthon/3.9/LINUX/X64/azure functions worker/utils/wrappers.ov", line 44, in call return func(*aras, **kwaras) File "/azure-
functions-host/workers/nvthon/39/||NIX/X64/azure functions worker/loadernv" line 134 in load function mod = imortlih imnort module(fullmodname)
File */sr/local/lib/python3.9/importlib/_init_py", line 127, in import_module return_bootstrap. ged_import(name[level:l, package, level) File "<frozen
importlib bootstrap>" line 1030 in acd import File " <frozen importlib bootstrans" line 1007 in find and load File "<frozen importlib bootstrans" line
986. in find and load unlocked File
"<frozen importlib. bootstrap›", line 680, in _load unlocked File " <frozen importlib. bootstrap external>", line 850, in
exec module File " ‹frozen importlib. bootstrap>" line 228. in call with frames removed File "/home/site/wwwroot/function-app/ init ov" line
§ in <modules from module.module_script import module_script
Overview
The triggering folder itself is straight forward and comes from the template. When I wanted to use another file, the structure and the right path was a problem. For running the file that is in the /module folder, you need to import the module like a regular package.
from module.module_script import module_script
To run the code inside the module folder you need to call the module script in your code
module_script()
Implementation
The module folder needs to have a empty file __init__.py
.
Conclusion
Make sure that the structure is right, there is a empty init file in the module folder and the import is written in a right form. This should get you started with Azure function app with Python
The code can be found from github Github link
Official documentation Microsoft documentation