【问题标题】:The listener for function was unable to start. Why?函数的侦听器无法启动。为什么?
【发布时间】:2018-06-28 09:17:12
【问题描述】:

当我从 Visual Studio 运行 azure 函数时出现以下错误。

发生 ScriptHost 错误 [1/19/2018 6:40:52 AM] 侦听器 函数“MyFunctionName”无法启动。 Microsoft.WindowsAzure.Storage:服务器遇到内部错误。 请稍后再试。

当我通过运行func host start 命令从命令提示符运行时。我收到以下警告。然后卡在了

实例 ID 获取的主机锁租约

.

未找到工作职能。尝试制作你的工作类别和方法 民众。如果您使用绑定扩展(例如 ServiceBus、Timers、 等)确保你已经调用了注册方法 启动代码中的扩展名(例如 config.UseServiceBus(), config.UseTimers() 等)。

Azure 函数版本:azure-functions-core-tools@2.0.1-beta.22 我正在使用存储帐户 Blob 容器和队列。

我正在连接到 Development Storage 帐户,我检查了 storage emulator 是否已启动。

{
  "IsEncrypted": false,
  "Values": {
    "ConnectionStrings:Default": "Server=.\\SQLEXPRESS; Database=TestDb; Trusted_Connection=True;",
    "ConnectionStrings:BlobStorageAccount": "UseDevelopmentStorage=true",

    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "AzureWebJobsDashboard": "UseDevelopmentStorage=true",
  }
}

仅供参考。

之前运行良好,但我在 Visual Studio 中收到此消息。

您的许可证已过期,必须更新。检查更新的 继续使用本产品的许可

所以我只是删除了 %localappdata%%temp%,然后我尝试运行 Azure 功能,之后,我开始获取

函数的监听器无法启动错误

这是否与我的 Visual Studio 订阅有关,或者我错误地删除了任何必需的文件?还是这与其他事情有关?

【问题讨论】:

  • 我认为我们需要更多信息才能为您提供帮助。我假设既然您遇到了问题,那么您正在谈论在 1.x 运行时上运行的 .NET 基础 Azure 函数?另外,您使用的是哪种触发器(存储队列、服务总线队列/主题、其他)?如果有任何方法可以将您的项目放在公开的某个地方(例如 GitHub),那将是很棒的,但如果您做不到,则可能需要更多的来回时间。
  • 谢谢德鲁,我更新了我的问题
  • 如果您的函数应用程序使用相同的主机 ID 在 Azure(或其他地方)运行,则该实例可能会占用租约,并且您本地运行的副本不会运行函数。确保所有您填写的连接数。
  • @JoeyCai 但它不适用于 VS?
  • @JoeyCai 对此有何更新?

标签: c# azure .net-core azure-functions


【解决方案1】:

对于遇到此问题的任何人,以下内容可能会有所帮助...

Azure Durable Functions 依赖于 TableStorage,最新版本的 Azurite (v3) 目前不支持 TableStorage。因此,拉取 Azurite 存储库并切换到 legacy-master (v2) 分支,然后运行 ​​npm run start

【讨论】:

  • 这是我的问题的原因。谢谢!
  • 要跟踪对 TableStorage 的 v3 支持,请参阅此问题:github.com/Azure/Azurite/issues/614。您可以安装 alpha 版本 npm install -g azurite@alpha(但未测试)。
  • 执行持久函数运行良好(使用 Azurite),但“常规函数”无法启动(就像它试图访问 Azure 存储模拟器而不是 Azurite)解决方案更改 "AzureWebJobsStorage" in @987654326 @ 到真正的本地连接字符串 AccountName=devstoreaccount1;AccountKey=*****;DefaultEndpointsProtocol=http;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1; 在任何情况下都强制使用 Azurite。
【解决方案2】:

我刚刚见证了这一点。此链接https://github.com/Azure/azure-functions-core-tools/issues/357 表示Local Storage Emulator 可能未运行。我停止调试。前往 Cloud Explorer 并打开本地节点以查看 blob 内容。这一定已经启动了本地存储模拟器。当我再次点击运行时,Azure Functions Tools 启动了。

【讨论】:

  • azure-webjobs-hosts 中的计时器已损坏。删除条目后已修复。
【解决方案3】:

如果您在本地通过存储模拟器运行,则运行 func settings add AzureWebJobsStorage UseDevelopmentStorage=true in local.settings.json

如果使用 func 使用普通 Azure 存储连接字符串,则必须在 local.settings.json 中设置 AzureWebJobsStorage

了解更多view

【讨论】:

  • 文件名必须是local.settings.json。设置必须是复数。
【解决方案4】:

对我来说,出现此错误是因为我没有安装和运行 Storage Emulator。您可以从以下链接将存储模拟器安装为 VS Code 插件。安装后转到 VS Code 命令面板并运行Azurite: Start Blob Service。然后在本地运行你的函数。它会正常工作的。

https://marketplace.visualstudio.com/items?itemName=Azurite.azurite

【讨论】:

  • Azurite 是在 Mac 和 Linux 上运行存储模拟器的方式。 VS Code 插件的替代方案是通过 Docker 容器运行并安装 Azurite npm 包:github.com/azure/azurite
【解决方案5】:

我在 Azure 函数中使用 ServiceBusTrigger 时遇到了这个问题。

在我的 Visual Studio 解决方案中,我有两个 Azure Functions,我为我的两个函数使用相同的 Subscription Name,其中一个函数是将数据发送到 Azure 服务总线,另一个函数用于接收数据。

发送

private const string _topicName = "factfinder_topic";
private const string _subscriptionName = "subs1";
private static ITopicClient _topicClient;
private static ILogger _logger;
[FunctionName("SendDataToSubscription")]
public static void Run([ServiceBusTrigger(_topicName, _subscriptionName, Connection = "ServiceBusConnectionString")] string mySbMsg, ILogger log) {
    _logger = log;
    PrepareSend().GetAwaiter().GetResult();
    _logger.LogInformation($ "C# ServiceBus topic trigger function processed message: {mySbMsg}");
}

接收

private const string _topicName = "factfinder_topic";
private const string _subscriptionName = "subs1";
[FunctionName("FetchDataFromSubscription")]
public static void Run([ServiceBusTrigger(_topicName, _subscriptionName, Connection = "ServiceBusConnectionString")] string mySbMsg, ILogger log) {
    log.LogInformation($ "C# ServiceBus topic trigger function processed message: {mySbMsg}");
}

您可以看到_subscriptionName 的值在这两种情况下都是subs1,这是错误的,所以在将其更改为我的其他订阅名称 (subs2) 之后FetchDataFromSubscription 函数,问题已解决。

【讨论】:

    【解决方案6】:

    我也遇到了同样的问题。退出 Visual Studio 并再次打开它解决了我的问题。

    【讨论】:

      【解决方案7】:

      我通过在 local.settings.json 文件中设置 UseDevelopmentStorage=false 解决了这个问题。

      {
      “IsEncrypted”:假,
      “价值观”:{
      "FUNCTIONS_WORKER_RUNTIME": "python",
      “AzureWebJobsStorage”:“UseDevelopmentStorage=false”
      }
      }

      【讨论】:

        【解决方案8】:

        我通过以下步骤解决了这个问题: 打开一个新终端并输入“azurite”。该程序将打开并保持窗口打开。 打开 Visual Studio 并尝试再次运行该功能。瞧。

        【讨论】:

          猜你喜欢
          • 2023-02-03
          • 2020-11-04
          • 2022-08-05
          • 2015-08-30
          • 2021-09-30
          • 2021-11-30
          • 1970-01-01
          • 1970-01-01
          • 2022-07-29
          相关资源
          最近更新 更多