im developing an azure function in python, when running it locally i have no problem but when i deploy it to Azure it gives me a Exception: TypeError: <azure.functions.decorators.function_app.FunctionBuilder object at 0x7f5015b52110> is not a module, class, method, or function.
My init.py is:
import azure.functions as func
import logging
import MegaVoceroTranslator.megaVoceroTranslator as megaVoceroTranslator
import shutil
def clean_up_tmp_folder():
tmp_path = 'tmp'
try:
shutil.rmtree(tmp_path)
logging.info(f"Successfully deleted {tmp_path}")
except FileNotFoundError:
logging.info(f"{tmp_path} does not exist")
except Exception as e:
logging.error(f"Error deleting {tmp_path}: {str(e)}")
app = func.FunctionApp()
@app.function_name(name="MegaVoceroTranslator")
@app.route(route="MegaVoceroTranslator")
async def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
try:
response = await megaVoceroTranslator.run()
clean_up_tmp_folder()
return response
except Exception as ex:
logging.info(f"Error occured: n{ex}")
clean_up_tmp_folder()
return func.HttpResponse(
"This HTTP triggered ended with error.",
status_code=500
)
And the full Exception im getting is:
Exception while executing function: Functions.MegaVoceroTranslator Result: Failure
Exception: TypeError: <azure.functions.decorators.function_app.FunctionBuilder object at 0x7f5015b52110> is not a module, class, method, or function.
Stack: File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/dispatcher.py", line 485, in _handle__function_load_request
self._functions.add_function(
File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/functions.py", line 366, in add_function
annotations = typing.get_type_hints(func)
File "/usr/local/lib/python3.10/typing.py", line 1856, in get_type_hints
raise TypeError('{!r} is not a module, class, method, '
All the examples i can find have the same structure i cant find where the problem is
I have tried changin the file nime to function_app, and more decoreators but nothig worked