Azure Function Can Invoke Javascript functions from another function. Is this expected?

Coder3455677 1 Reputation point
2020-06-04T00:27:59.34+00:00

I'm not sure if this is expected behavior and if I can fully rely on this however. I have one Azure Function, containing multiple Javascript functions.

And it appears that I'm able to call these Javascript functions from other Azure functions. Is this expected, and can I depend on this?

I'll illustrate this with an example below

// Azure Function 1 :
testFunctionA = () => {
    console.log("This is the 1st function in another azure function");
};

testFunctionB = () => {
    console.log("This is the 2nd function in another azure function");
};

testFunctionC = () => {
    console.log("This is the 3d function in another azure function");
};


module.exports = {
    testFunctionA
};



// Azure function 2:
module.exports = async function (context, req) {
    context.log("JavaScript HTTP trigger function processed a request.");

    testFunctionA();
    testFunctionB();
    testFunctionC();
};



When invoking the HTTP Trigger Azure Function 2 the output is as following Eventhough both functions are seperate Azure functions:

This is the 1st function in another azure function
index.js:6
This is the 2nd function in another azure function
index.js:10
This is the 3d function in another azure function
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,212 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Urnun 9,651 Reputation points Microsoft Employee
    2020-06-04T23:26:21.467+00:00

    Hello @Coder3455677

    Ideally, each of your functions should be stateless components that use dependency management for additional functionalities. If you'd like to run a series of functions that carry out their own operations, Functions Chaining pattern in the Durable Functions would be the right fit.

    1 person found this answer helpful.
    0 comments No comments