函数 'Function1' 的侦听器无法启动
The listener for function 'Function1' was unable to start
虽然 运行 一个简单的计时器在本地触发 Azure 函数,但我遇到了以下错误。
我使用 Visual Studio 2019 创建了带有计时器触发器的新 Azure Functions 项目。
我安装了 Azure 开发工作负载。
代码:
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace FunctionApp1
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("*/12 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
}
错误:
[2021-11-24T15:45:29.878Z] The listener for function 'Function1' was unable to start.
[2021-11-24T15:45:29.880Z] The listener for function 'Function1' was unable to start. Azure.Storage.Blobs: Server encountered an internal error. Please try again after some time.
RequestId:3bb00ada-83ec-4685-987b-5d4b51cb39db
Time:2021-11-24T15:45:29.5583585Z
[2021-11-24T15:45:29.880Z] Status: 500 (Server encountered an internal error. Please try again after some time.)
[2021-11-24T15:45:29.881Z] ErrorCode: InternalError
建议关闭防火墙。看来防火墙也是我的问题。当禁用防火墙不是一个选项时,有什么方法可以克服这个问题吗?
经过所有讨论,很高兴您的问题得到解决。
这是我在本地环境中测试过的帮助其他社区成员的解决方案:
代码如下:
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
Function1.cs
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace KrishTimerTriggerNetCore31
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("*/12 * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
}
输出:
当您在 Visual Studio 中使用计时器触发器模板创建 azure 函数项目时,默认情况下您的 local.settings.json
文件包含此值 "AzureWebJobsStorage": "UseDevelopmentStorage=true"
如果把UseDevelopmentStorage
改为none
,那么也会出现同样的错误:
确保所有必需的应用程序都已安装并根据您的要求保持最新,例如 Azure Functions 核心工具版本、Azure 存储模拟器(本地)、.Net 核心运行时版本和 SDK 以及安装时的扩展 Visual Studio .
虽然 运行 一个简单的计时器在本地触发 Azure 函数,但我遇到了以下错误。
我使用 Visual Studio 2019 创建了带有计时器触发器的新 Azure Functions 项目。
我安装了 Azure 开发工作负载。
代码:
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace FunctionApp1
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("*/12 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
}
错误:
[2021-11-24T15:45:29.878Z] The listener for function 'Function1' was unable to start.
[2021-11-24T15:45:29.880Z] The listener for function 'Function1' was unable to start. Azure.Storage.Blobs: Server encountered an internal error. Please try again after some time.
RequestId:3bb00ada-83ec-4685-987b-5d4b51cb39db
Time:2021-11-24T15:45:29.5583585Z
[2021-11-24T15:45:29.880Z] Status: 500 (Server encountered an internal error. Please try again after some time.)
[2021-11-24T15:45:29.881Z] ErrorCode: InternalError
经过所有讨论,很高兴您的问题得到解决。
这是我在本地环境中测试过的帮助其他社区成员的解决方案:
代码如下:
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
Function1.cs
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace KrishTimerTriggerNetCore31
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("*/12 * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
}
输出:
当您在 Visual Studio 中使用计时器触发器模板创建 azure 函数项目时,默认情况下您的 local.settings.json
文件包含此值 "AzureWebJobsStorage": "UseDevelopmentStorage=true"
如果把UseDevelopmentStorage
改为none
,那么也会出现同样的错误:
确保所有必需的应用程序都已安装并根据您的要求保持最新,例如 Azure Functions 核心工具版本、Azure 存储模拟器(本地)、.Net 核心运行时版本和 SDK 以及安装时的扩展 Visual Studio .