Multiple Python Azure functions in the same function app requiring different packages versions

louey Bnecheikh lehocine 20 Reputation points
2024-11-09T20:43:22.37+00:00

Hi,

We have a project that requires multiple azure functions. The first plan was to host all the functions on the same function app using the consumption plan. From the Microsoft documentation I understood that functions on the same function app share the same execution process which mean they need to use the same packages version, am I right ?

I have seen an option for .NET functions to run as isolated functions but this is not possible for Python runtime.

Is the only solution for functions with different requirements versions is to separate them into different function apps ?

I am wondering also, as functions in the same function app share the same execution process, if it is worth hosting more than one function in the same app. The reason is that, as the same process is used, once a function is trigerred, all other functions code is compiled and stored in memory even if they weren't triggered, this makes cost higher than if the functions were splitted into different apps.

Your feedbacks would be very appreciated

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

Accepted answer
  1. Pinaki Ghatak 5,230 Reputation points Microsoft Employee
    2024-11-11T10:12:54.4466667+00:00

    Hello @louey Bnecheikh lehocine

    Yes, you are correct that functions in the same function app share the same execution process and therefore need to use the same package versions.

    However, there is a solution to this problem.

    You can use virtual environments to isolate the package versions for each function. To do this, you can create a virtual environment for each function and install the required packages for that function in its own virtual environment.

    Then, you can specify the path to the virtual environment in the function's configuration file. This way, each function will use its own set of packages and you can have multiple functions with different package versions in the same function app.

    Regarding your question about whether it's worth hosting more than one function in the same app, it really depends on your specific use case.

    If your functions are related and share resources, it might make sense to host them in the same app.

    However, if they are completely unrelated and have different resource requirements, it might be more cost-effective to host them in separate apps.

    I hope this helps and clarifies your question

    0 comments No comments

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.