Azure Function Error

Niren Adhikary (NAD) 146 Reputation points
2022-09-02T13:36:08.717+00:00

Hi,

I am facing issue with azure function deployment as the azure functions returns the below error.

Result: Failure Exception: ModuleNotFoundError: No module named 'requests'. Please check the requirements.txt file for the missing module. For more info, please refer the troubleshooting guide: https://aka.ms/functions-modulenotfound Stack: File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py", line 359, in _handle__function_load_request func_request.metadata.entry_point) File "/azure-functions-host/workers/python/3.7/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.7/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 40, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/loader.py", line 127, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.7/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/home/site/wwwroot/functionname/init.py", line 6, in

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,908 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2022-09-12T18:10:25.57+00:00

    @Niren Adhikary (NAD) Thanks for reaching out and apology for the delay. Please let me know if you are still facing the issue.

    Sharing for community:
    As you are using requests module in your azure function and when there is a missing dependency, you should see the below error message in application insights that you have configured for your function app. In case if the changes are not saved correctly to your local file then the deployed code will not have the new changes.
    ModuleNotFoundError: No module named 'requests' looks like you have not installed the module requests.

    If you have any requirement where you need to use any other packages that are not predefined in the functions then you need to add the names or names along with versions of the required packages to the requirements.txt file. Please refer to this document for more details

    To troubleshoot these types of errors you can always refer to this document.

    Your requirement.txt file will be as below per the exception but in case if you are using any other packages then please make sure that you have defined the same.

    azure-functions  
    requests  
    

    For your reference, I will suggest you to review this article which will can help you to monitor azure function. Once you have set it up you can see the above error in application insights. You can also see these exceptions in the storage account that you have configured on your function app.

    Please refer to Azure function python document to get more familiar with the development.

    Please let me know if you are still facing the issue so I can assist you further.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.