gpt4 book ai didi

Azure功能门户: "Code + Test" section can update code,但更改未生效

转载 作者:行者123 更新时间:2023-12-03 06:10:34 24 4
gpt4 key购买 nike

在Azure函数和“代码+测试”部分中,我可以编辑代码并保存更改。我可以从前端确认更改已保存。然而,当我开始测试代码时,打印的日志是基于我进行任何更改之前的原始代码。这些变化从未发生。

这是非常简单的更改,例如打印一条新消息:从这段代码来看:

context.log("my message: ", myMessage);

这段代码:

context.log("Test123 my message: ", myMessage);

当我执行测试/运行时,日志仍然打印“我的消息:”而不是“Test123我的消息:”

我不知道为什么会发生这种情况。从用户的角度来看,这非常令人困惑。我认为 Azure 门户总体上缺乏良好的设计和质量控制。

有人可以解释一下吗?

这是代码:

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

const sealWorkerFunction: 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 message = req.body;
context.log("type of message: ", typeof message);
context.log("Test123 my message: ", message);


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

export default sealWorkerFunction;



最佳答案

根据这个document , 基于 Typescript 的函数不支持门户编辑

要更改基于 typescript 的函数中的任何代码,请确保在本地更改代码并将其部署在函数应用中。

我尝试在 Portal 中使用 HttpTrigger 创建一个 Node-js 函数应用程序,它默认使用 Javascript 代码,而 Portal 编辑中不支持 Typescript 代码,请参阅以下内容:-

enter image description here

当我在基于 Javascript 的函数应用程序中更改日志上下文时,它会得到如下反射(reflect):-

enter image description here

我用您的代码在本地更新了我的 Typescript 代码,并将其部署在我的 Node-js 函数应用程序中,如下所示,它给出了有关该函数为只读的警告:-

enter image description here

关于Azure功能门户: "Code + Test" section can update code,但更改未生效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76849529/

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