Failure Exception: ModuleNotFoundError: No module named 'azure.core'. Please check the requirements.txt file for the missing module.

Lohit K M 1 Reputation point
2022-11-23T10:39:50.567+00:00

Trying to deploy the function app code using custom template with code in zip using WEBSITE_RUN_FROM_ZIP(zip sas url).
i have SCM_DO_BUILD_DURING_DEPLOYMENT, ENABLE_ORYX_BUILD in app settings.
function is getting deployed. while executing getting 500 internal error
in app files i have requirements.txt from where packages are not getting and throwing :
Result: Failure Exception: ModuleNotFoundError: No module named 'azure.core'. 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.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 355, 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 127, 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

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

1 answer

Sort by: Most helpful
  1. Alistair Ross 7,106 Reputation points Microsoft Employee
    2022-11-23T18:12:24.013+00:00

    Hello @Lohit K M

    I cannot speak for all scenarios, but issue I have had in the past include:

    • The issue could be because the application setting should be WEBSITE_RUN_FROM_PACKAGE (Issue 1041).
    • Another consideration could be that because you are deploying a package, you need to include all the dependencies in your package. Therefore, you will need to build application before the function deployment. Read through this page to understand how to deploy as a package. https://learn.microsoft.com/en-us/azure/azure-functions/run-functions-from-deployment-package
    • My understanding is that you shouldn't be setting SCM_DO_BUILD_DURING_DEPLOYMENT, ENABLE_ORYX_BUILD
      If your project needs to use remote build, don't use the WEBSITE_RUN_FROM_PACKAGE app setting. Instead add the SCM_DO_BUILD_DURING_DEPLOYMENT=true deployment customization app setting. For Linux, also add the ENABLE_ORYX_BUILD=true setting.

    I've used this function in the past as a template for my python deployments. https://github.com/Azure/Azure-Sentinel/tree/master/DataConnectors/AWS-S3-AzureFunction

    I hope this helps provide you with the information you need. If it does, please make sure to mark the question as answered so it helps other people in future.

    Kind regards

    Alistair

    0 comments No comments