Azure functions: Python Httptrigger with multiple script files

SRAVANTHI GAALI 1 Reputation point
2020-06-25T10:10:17.5+00:00

Created Azure function using template HTTPTrigger using python as programming language.
added multiple python files, unable to import a method/class in init.py.

Error:
[6/25/2020 9:56:17 AM] Worker failed to function id 73a7ea01-48eb-49ca-9bb1-99a5cc6aad52.
[6/25/2020 9:56:17 AM] Result: Failure
Exception: ModuleNotFoundError: No module named 'azure_pipelinev1'
Stack: File "C:\Users\Sravanthig\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.6/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 243, in _handle__function_load_request
func_request.metadata.entry_point)
File "C:\Users\Sravanthig\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.6/WINDOWS/X64\azure_functions_worker\loader.py", line 66, in load_function
mod = importlib.import_module(fullmodname)
File "C:\Users\Sravanthig\AppData\Local\Programs\Python\Python36\lib\importlib__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\Sravanthig\Documents\AzurePipelineTest\AzurePipeline__init__.py", line 4, in \

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

1 answer

Sort by: Most helpful
  1. Amir Katz 80 Reputation points
    2023-01-31T11:33:52.0166667+00:00

    I think the problem is the syntax of your import statement.

    I have a similar situation - I have a main file (function_app.py) and 3 additional Python files. For example, one of them is called azure_blob_client.py. In it there is a class named AzureBlobCSV.

    So in the main file I have the import statement shown below. As you can see, I just specify the file name, without any relative dot or dot-dot.

    This works fine.

    """azure_blob_client.py - Azure Storage Blob interface."""
    import logging
    from azure.storage.blob import BlobServiceClient, ContentSettings
    
    class AzureBlobCSV(object):
      yada-yada-yada
    
    """function_app.py - This is the main Azure Function file."""
    import logging
    from azure_blob_client import AzureBlobCSV
    

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.