node.jstypescriptazure-functions

NodeJS Azure Functions - Export Functions from different folder nest levels of same repository


Is it possible to provision multiple Azure Functions from different levels of nested folders when using VS Code?

Example:

| - Function1 *(function)*
| - - index.ts
| - - function.json
| - Foo *(folder only)*
| - - Foo1 *(function)*
| - - - index.ts
| - - - function.json
| - - Foo2 *(function)*
| - - - index.ts
| - - - function.json
| - Bar  *(folder only)*
| - - Bar1 *(function)*
| - - - index.ts
| - - - function.json
| - - Bar2 *(function)*
| - - - index.ts
| - - - function.json

I haven't seen any examples that support multiple levels of nesting. The reason for the nesting is that if all of the Foo1, Foo2, Bar1, Bar2 folders were at the root, we would end up with little organization of dozens and dozens of functions. Looking for a better way to improve code navigation within the repo.

The end result I am after is that all of the functions are detected and registered. Function1, Foo1, Foo2, Bar1, Bar2. I can adjust the "route" property in the respective function.json files to get the provisioned Azure urls to account for the folder structure.

Thanks


Solution

  • No, it is not possible. Every language stack of azure function all search trigger under the function app's folder but will not search the sub folder.

    The structure of azure function app should be like this:

    FunctionsProject
     | - MyFirstFunction
     | | - index.js
     | | - function.json
     | - MySecondFunction
     | | - index.js
     | | - function.json
     | - SharedCode
     | | - myFirstHelperFunction.js
     | | - mySecondHelperFunction.js
     | - node_modules
     | - host.json
     | - package.json
     | - extensions.csproj
    

    This is the offcial document:

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-node#folder-structure