NodeJS中的Azure函数,发布后触发器不可用

nuypyhwy  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(124)

运行“func start”函数时可用,但发布后不可用。
如果我运行“func azure functionapp publish functiontest”,没有部署任何函数。

func azure functionapp publish functiontest                    
Getting site publishing info...
[2023-11-17T20:57:57.684Z] Starting the function app deployment...
Uploading package...
Uploading 28.18 MB [##############################################################################]
Upload completed successfully.
Deployment completed successfully.
[2023-11-17T21:00:04.675Z] Syncing triggers...
Functions in functiontest

字符串
我有以下package.json

"version": "1.0.0",
    "description": "",
    "main": "dist/index.js",


我在package.json中使用的依赖项:
“@azure/functions”:“^4.0.1”,

import {app} from "@azure/functions";

app.post('myendpoint', { route: 'test/myendpoint', handler: myHandler });


我在index. ts中有方法。在创建npx tsc dist/index.js和其他js文件之后。

ltqd579y

ltqd579y1#

我在你的代码中做了一些修改,以便能够使用**func azure functionapp publish funcappname**部署JS HTTP触发器函数
发布命令:-

产品代码:

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

const myHandler: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
    context.log('HTTP trigger function processed a request.');

    if (req.body && req.body.name) {
        context.res = {
            body: `Hello, ${req.body.name}! This is an Azure Functions HTTP trigger.`,
        };
    } else {
        context.res = {
            status: 400,
            body: "Please pass a name in the request body.",
        };
    }
};
export default myHandler;

字符串

命令:-

func azure functionapp publish funcappname

输出:

x1c 0d1x的数据

Postman输出:



在Function应用程序中成功部署和触发函数:-


相关问题