Internal Server Error 500 for Published Function

Raddy 1 Reputation point
2021-08-27T02:53:44.127+00:00

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
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,518 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 69,931 Reputation points
    2021-08-27T03:20:10.753+00:00

    @Raddy 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.