NodeJS Azure Functions - 从同一存储库的不同文件夹嵌套级别导出函数

Sol*_*812 4 node.js typescript azure-functions

使用 VS Code 时是否可以从不同级别的嵌套文件夹预配多个 Azure Functions?

例子:

| - 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
Run Code Online (Sandbox Code Playgroud)

我还没有看到任何支持多层嵌套的示例。嵌套的原因是,如果所有 Foo1、Foo2、Bar1、Bar2 文件夹都位于根目录,那么我们最终将无法组织数十个函数。寻找更好的方法来改进存储库中的代码导航。

我追求的最终结果是所有功能都被检测到并注册。函数 1、Foo1、Foo2、Bar1、Bar2。我可以调整相应 function.json 文件中的“route”属性,以获取预配的 Azure URL 来说明文件夹结构。

谢谢

1_1*_*1_1 5

不,这是不可能的。azure function 的每个语言堆栈都会在函数应用程序的文件夹下触发搜索,但不会搜索子文件夹。

azure function app的结构应该是这样的:

FunctionsProject
 | - MyFirstFunction
 | | - index.js
 | | - function.json
 | - MySecondFunction
 | | - index.js
 | | - function.json
 | - SharedCode
 | | - myFirstHelperFunction.js
 | | - mySecondHelperFunction.js
 | - node_modules
 | - host.json
 | - package.json
 | - extensions.csproj
Run Code Online (Sandbox Code Playgroud)

这是官方文件:

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