Azure Function应用程序(V3,nodejs)在zip部署后没有功能

ioekq8ef  于 2023-08-07  发布在  其他
关注(0)|答案(1)|浏览(102)

我正在使用Azure Function Nodejs Linux和编程模型V3。
注意是V3,不是V4;
我看了docs:

  1. https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-node?tabs=typescript%2Clinux%2Cazure-cli&pivots=nodejs-model-v3#configure-function-entry-point
  2. https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/azure-functions/deployment-zip-push.md
    项目如下:
<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)"
  }
}


但是,在zip部署之后,azure函数应用门户中没有任何函数。
我可以确认与azure函数相关的存储在site/wwwroot中上传了正确的代码。
我错过了什么?

yftpprvb

yftpprvb1#

发表评论作为社区的答案:

  • 当您将函数部署为zip包时,部署引擎不会运行任何构建自动化,因为它假定ZIP文件已准备好运行。

要在函数应用程序中查看已部署的函数,请执行以下操作:
进入Function App=>Settings=>Configuration=>Add Application Settings,点击Add:

  • 添加设置SCM_DO_BUILD_DURING_DEPLOYMENT=true。这是为了在 *Linux函数应用 * 上启用远程构建过程。


的数据

  • 将应用程序重新部署到功能应用程序。
  • 现在,您将可以在 Portal=>Function App中看到您的函数。
    参考文献:

Azure Functions的Zip推送部署

相关问题