当 运行 定时器函数时,函数 'Function1' 的侦听器无法启动

The listener for function 'Function1' was unable to start when running a timer function

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

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}");
    }
}

这是我为确定此问题原因所做的解决方法:

  1. 使用给定的计时器 "0 * * * * *" 创建了类型为 Timer TriggerAzure Function(堆栈:.NET 3.1),并且从 Azure 门户中创建的存储帐户给出的连接字符串,已成功 运行ning(在本地):

2。从 Azure 门户中删除存储帐户并尝试在本地 运行 函数,这给了我错误:The listener for function Function1 was unable to start.

恢复存储账户然后部署到Azure Portal Function App并且运行在云端也成功:

在 Azure 云中,是的,因为 @Skin 说这将是一个存储帐户配置问题。

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

  • 检查 AzureWebJobsStorage 值是否包含正确的存储帐户连接字符串。
  • 检查存储帐户是否被删除。
  • 检查 Function App 中的网络选项,可能是防火墙 blocking/restricting 对关联存储帐户的访问。

这是一个防火墙问题。 在存储帐户 > 网络 > 防火墙和虚拟网络下添加了适当的虚拟网络和子网