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

Azure Function Node.js V3部署Zip包后无函数显示问题排查

问题:Linux环境下Node.js Azure Function V3模型Zip部署后无函数显示

我使用Linux环境的Azure Function Node.js,采用V3编程模型,按相关文档操作后,Zip部署完成且存储账户site/wwwroot目录代码上传正确,但Azure Function App门户中无任何函数显示。

项目信息

项目结构

<root-directory>
├── README.md
├── dist
├── azure_function.zip
├── bin
├── dependencies
├── host.json
├── local.settings.json
├── node_modules
├── package-lock.json
├── package.json
├── sealworker
│   ├── constants
│   ├── errors
│   ├── function.json
│   ├── index.ts
│   ├── interfaces
│   ├── sample.dat
│   ├── sealworkerfunction.ts
│   ├── services
│   ├── utils
│   └── worker.ts
└── tsconfig.json

关键文件内容

function.json

{
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ],
  "scriptFile": "../dist/sealworker/index.ts"
}

index.ts

import { AzureFunction, Context, HttpRequest } from "@azure/functions";
import { workerExec } from "./worker";

const httpTrigger: AzureFunction = async function (
  context: Context,
  req: HttpRequest
): Promise<void> {
  const name = req.query.name || (req.body && req.body.name);
  const responseMessage = name
    ? "Hello, " + name + ". This HTTP triggered function executed successfully."
    : "This HTTP triggered function executed successfully. Pass a name in the query string or in the req body for a personalized response.";

  context.log(`Http function processed req for url "${req.url}"`);
  const x = req.body;
  context.log("x: ", x);

  context.res = {
    // status: 200, /* Defaults to 200 */
    body: responseMessage,
  };
};

export default httpTrigger;

host.json

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[3.*, 4.0.0)"
  }
}

排查方向及解决方法

  • 修正scriptFile路径:Linux环境路径区分大小写,且Azure Functions运行时仅能执行编译后的.js文件。将function.json中的scriptFile修改为../dist/sealworker/index.js,同时确认TypeScript编译后dist目录下存在该文件。
  • 确保编译步骤完成:部署前必须执行npm run build(需在package.json中配置编译脚本,如"build": "tsc"),确保dist目录生成完整的编译产物,且zip包包含该目录的全部内容。
  • 核对运行时版本:在Azure门户的函数应用配置中,确认FUNCTIONS_EXTENSION_VERSION设置为~3,匹配V3编程模型要求。
  • 检查zip包结构:zip包根目录需直接包含host.json、package.json以及sealworker、dist等目录,不能将整个项目根目录嵌套在zip内部。
  • 查看运行日志:在Azure门户的「监测」>「日志」中查看运行时日志,排查是否存在文件路径错误、依赖缺失或编译失败等报错。
  • 配置package.json入口:V3模型下,需在package.json中设置main字段指向正确路径,如"main": "dist/sealworker/index.js",确保运行时能找到函数入口。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 01:47:09