You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Node.js v20.14.0下Azure Functions v4作业函数未加载问题求助

解决Azure Functions v4模型下“No job functions found”报错的额外排查步骤

你当前环境:Node.js v20.14.0,@azure/functions ^4.5.0、durable-functions ^3.1.0,Azure Functions v4模型,已尝试官方文档排查、更新extensionBundle配置、设置FUNCTIONS_WORKER_RUNTIME、升级core tools,但仍出现No job functions found. Try making your job classes and methods public (NODEJS v4)报错,可补充以下排查步骤:


1. 检查函数文件的导出格式

Azure Functions v4模型要求函数必须通过app实例注册,禁止使用旧版module.exports导出方式。确保函数代码遵循以下标准结构:

const { app } = require('@azure/functions');

app.http('HttpTriggerDemo', {
    methods: ['GET', 'POST'],
    authLevel: 'anonymous',
    handler: async (request, context) => {
        context.log('处理HTTP请求');
        return { body: '请求成功' };
    }
});

2. 验证函数文件的位置与命名

  • 默认要求函数文件放在项目根目录的src文件夹下;若自定义路径,需在host.json中通过functions字段明确指定。
  • 文件名避免特殊字符,建议使用小写字母+短横线格式(如http-trigger-demo.js),减少潜在识别问题。

3. 检查Durable Functions的集成逻辑

使用durable-functions v3.x配合v4模型时,必须先初始化扩展再注册函数:

const { app } = require('@azure/functions');
const { initDurableFunctions } = require('durable-functions');

// 必须先调用初始化方法
initDurableFunctions(app);

// 注册Durable HTTP触发函数
app.durableHttpStart('StartOrchestration', {
    handler: async (request, context) => {
        const client = app.getDurableClient(context);
        const instanceId = await client.startNew(request.params.orchestratorName, undefined, request.body);
        return client.createCheckStatusResponse(request, instanceId);
    }
});

确保编排器、活动函数均通过app实例注册,而非旧版的导出方式。

4. 清理依赖缓存并重装

依赖缓存损坏可能导致加载异常,执行以下命令重置依赖:

rm -rf node_modules
rm package-lock.json
npm install

完成后重新启动函数应用。

5. 检查package.json启动脚本

确保package.json中配置了正确的启动命令,避免直接调用func start导致依赖加载异常:

"scripts": {
    "start": "func start",
    "build": "echo \"Build completed\""
}

启动时使用npm start命令。

6. 校验host.json配置合法性

确保host.json无冲突配置,示例如下(仅保留必要配置):

{
    "version": "2.0",
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[4.*, 5.0.0)"
    }
}

移除任何与v4模型不兼容的旧版配置(如错误的runtime字段)。


内容的提问来源于stack exchange,提问作者art

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 06:31:01