我正在使用Azure Function Nodejs Linux和编程模型V3。
注意是V3,不是V4;
我看了docs:
- 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
- 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
中上传了正确的代码。
我错过了什么?
1条答案
按热度按时间yftpprvb1#
发表评论作为社区的答案:
要在函数应用程序中查看已部署的函数,请执行以下操作:
进入Function App=>Settings=>Configuration=>Add Application Settings,点击Add:
SCM_DO_BUILD_DURING_DEPLOYMENT=true
。这是为了在 *Linux函数应用 * 上启用远程构建过程。的数据
参考文献:
Azure Functions的Zip推送部署