5

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

1
  • No, it is not possible. The function core tools will only search trigger under the function app folder but not the sub folder.
    – Cindy Pau
    Jul 7, 2020 at 1:42

1 Answer 1

5

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

3
  • I have seen this before. Thanks for the reply. Is it possible to leverage the postbuild functionality to accomplish this? Bottom post at: github.com/Azure/azure-functions-core-tools/issues/858
    – Solo812
    Jul 7, 2020 at 14:24
  • @Solo812 What I am very sorry to reply too late. The link you provide is also only one root folder. But in your description there seems more than one. You can use this to change the root folder that convert from: { "compilerOptions": { "target": "es6", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "outDir": "dist", "rootDir": "Foo", "strict": true, "allowJs": true }, "include": [ "foo/**/*" ] }
    – Cindy Pau
    Jul 20, 2020 at 9:04
  • @Solo812 I think there is no good way to convert multiple nested triggers from multiple different folders to a target folder.
    – Cindy Pau
    Jul 20, 2020 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.