How to handle mutiple .py files in Azure Functions?

Victor Skou Fertin 25 Reputation points
2024-06-11T18:18:26.8966667+00:00

Hi all,

I am trying to deploy an azure function which utilizes a lot of my own scripts and classes, which are to be executed via a blob trigger. I do not want to copy all the code into the function_app.py, but rather have it imported but have yet to succeed.

I have tried to host the code on Github and then import it. This was successful when testing locally using Azure Function Core Tools and VS Code, but did not work when deployed and did not even show up in the functions list in the portal.

Second attempt was to work with subfolders (see image), but again: worked locally but not when deployed.

User's image

Do anyone have an idea how to handle this or why my previous attempts has not worked?

Thanks. :)

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

Accepted answer
  1. Pieter de Bruin 321 Reputation points Microsoft Employee
    2024-06-14T10:00:29.4+00:00

    Hi Victor,

    Sorry to hear about your experience.

    Can you explain more about your environment and steps to reproduce?

    From the screenshot it looks like you just have other .py files in your Function project which are in a folder and you also tried without folder.

    I just tried to add a .py file with a regular method to the project, which worked locally and in Azure.

    • mytest.py with myfunc()
    • imported using: from mytest import myfunc
    • call the myfunc() in function_app.py

    https://github.com/pdebruin/functionspy/tree/main/1function

    Hope that helps,

    Pieter


0 additional answers

Sort by: Most helpful

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.