gpt4 book ai didi

具有触发计时器的 Azure Functions 不会在监视器下显示日志

转载 作者:行者123 更新时间:2023-12-05 05:01:49 26 4
gpt4 key购买 nike

我正在测试我的 Azure Functions,并遇到一个有趣的问题。我想查看某个函数是否正在运行以及结果。我正在打开该函数,然后我的函数名为 getTokenRefresh。显然,这个功能从未启动过。

enter image description here

几个小时后,我决定打开 Application Insights。惊喜!所有日志都在那里。

enter image description here

如果我从门户运行某个功能并再次打开监视器并单击“日志”选项卡,我看不到任何日志。同样,我只能在 Application Insights 中找到所有内容。

另一个有趣的事情是这个Azure Functions中的其他函数,向我展示所有细节(相信我是相同的函数)。

enter image description here

从代码的角度来看,我在所有函数中使用依赖注入(inject),例如:

public class GetTokenRefreshTimer
{
private ILogger _log;

public GetTokenRefreshTimer(ILogger<GetTokenRefreshTimer> log)
{
_log = log;
}

[FunctionName("getTokenRefreshTimer")]
public async Task Run([TimerTrigger("0 */20 * * * *")]TimerInfo myTimer)
{
_log.LogInformation("GetTokenRefresh starts");
}
}

最佳答案

azure 函数的日志很脆弱。所以有时看不到日志,但这并不意味着azure函数没有运行。

如果您想知道该函数正在运行,您需要转到 Azure 函数的 kudu 并查看函数应用程序的日志文件。(Application Insights 中的日志来自此位置。)

日志文件位于以下位置:

打开浏览器并转到 https://yourfunctionappname.scm.azurewebsites.net/DebugConsole,然后单击 LogFiles/Application/Functions/Function/yourtriggername 。您将在此位置找到日志文件。

关于具有触发计时器的 Azure Functions 不会在监视器下显示日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62559770/

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