question

Raddy-5566 avatar image
0 Votes"
Raddy-5566 asked MayankBargali-MSFT edited

Internal Server Error 500 for Published Function

Hello all.

My Azure Function works well locally but it does not work when I published it.
Am not sure why it mentions that it could not find the module when it could work locally. Any ideas how to make it work?

 Result: Failure Exception: ModuleNotFoundError: No module named 'poseidon'. Troubleshooting Guide: https://aka.ms/functions-modulenotfound Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 305, in _handle__function_load_request func = loader.load_function( File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 42, in call raise extend_exception_message(e, message) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 40, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/loader.py", line 83, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/home/site/wwwroot/rafaAPI/__init__.py", line 5, in <module> from poseidon import poseidon


PYTHON CODE

     import logging
        
     import azure.functions as func
        
     from poseidon import poseidon
        
        
     def main(req: func.HttpRequest) -> func.HttpResponse:
         logging.info('Python HTTP trigger function processed a request.')
        
         accessKey = 'XX'
         secretKey = 'XX'
        
         url = 'https://XX/app-portal-service/v2.0/login'
        
         data = {"account": "XX", "password": "XX"}
        
         req = poseidon.urlopen(accessKey, secretKey, url, data)
            
         #name = 'mynameis'
         #return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
         return func.HttpResponse(f"Hello, {req['data']['accessToken']}. This HTTP triggered function executed successfully.")



azure-functions
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MayankBargali-MSFT avatar image
0 Votes"
MayankBargali-MSFT answered MayankBargali-MSFT edited

@Raddy-5566 As per the error message you module poseidon was not found. Please make sure that you have define this package in your requirements.txt file as mentioned in this document.

But in case if those module or dependencies cannot be installed using pip then you need to use build native dependencies or enable remote build.
You can refer to python troubleshooting document for more details.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I've defined two packages in the file. "poseidon" and "simplejson"
However, I'm getting new errors.

 Result: Failure Exception: SyntaxError: Missing parentheses in call to 'print'. Did you mean print(cmd)? (ssh.py, line 93) Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 305, in _handle__function_load_request func = loader.load_function( File "/azure-functions-
0 Votes 0 ·

126992-error.png



details of full error

0 Votes 0 ·
error.png (343.9 KiB)

@Raddy-5566 As per the full stack there is issue while importing the Droplets, connect etc and the excepton is coming from the poseidon package itself. If I look into the poseidon I don't see details on the python version that is supported. But looking into the release history I can see the latest version released on 20th Aug 2014. When I review the python version release date looks like the python version supported might be 3.4.1 version or less for the poseidon. Currently azure function python supports the version that are mentioned in this document and the poseidon would not be supported in python 3.8 and above.

0 Votes 0 ·