gpt4 book ai didi

c# - 运行计时器函数时,函数 'Function1' 的监听器无法启动

转载 作者:行者123 更新时间:2023-12-03 07:08:23 26 4
gpt4 key购买 nike

当我在 Azure 云中运行计时器函数应用程序时,出现以下错误。这只是一个基本代码,我希望日志能够显示在 Insight 中。

Exception message

public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("0 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}

enter image description here

enter image description here

最佳答案

以下是我为确定此问题原因而采取的解决方法:

  1. 使用给定的计时器“0 * * * * *”创建了计时器触发器类型的Azure Function(堆栈:.NET 3.1) 以及在 Azure 门户中创建的存储帐户给出的连接字符串,该帐户已成功运行(在本地):

enter image description here

2。从 Azure 门户删除了存储帐户并尝试在本地运行该函数,这给了我错误:函数 Function1 的监听器无法启动。

enter image description here

恢复存储帐户,然后部署到 Azure Portal Function App 并在云中成功运行:

enter image description here

在 Azure 云中,是的,如 @Skin说这是存储帐户配置问题。

解决此问题的几个步骤是:

  • 检查 AzureWebJobsStorage 值是否包含正确的存储帐户连接字符串。
  • 检查存储帐户是否已删除。
  • 检查功能应用中的网络选项,可能是防火墙阻止/限制了对关联存储帐户的访问。

关于c# - 运行计时器函数时,函数 'Function1' 的监听器无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70984814/

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