question

Coder3455677-1028 avatar image
0 Votes"
Coder3455677-1028 asked ·

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

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
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MikeUrnun avatar image
0 Votes"
MikeUrnun answered ·

Hello @Coder3455677-1028

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.


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.