gpt4 book ai didi

node.js - Azure Function 应用程序(V3、nodejs)在 zip 部署后没有任何功能

转载 作者:行者123 更新时间:2023-12-03 01:59:36 35 4
gpt4 key购买 nike

我正在使用 Azure Function Nodejs linux 进行编程模型 V3。

注意这是V3,而不是V4;

我已关注文档:

  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 中上传了正确的代码。

我错过了什么?

最佳答案

发布我的评论作为社区的答案:

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

要在函数应用中查看已部署的函数,

转到您的功能应用=>设置=>配置=>添加应用程序设置,单击“添加”:

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

enter image description here

  • 将您的应用重新部署到功能应用。
  • 现在,您将能够在 Portal=>Function App 中查看您的函数。

引用文献:

Zip push deployment for Azure Functions

关于node.js - Azure Function 应用程序(V3、nodejs)在 zip 部署后没有任何功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76832935/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com