出现错误“函数‘Functions.functionname’的监听器无法启动。”使用 node.js 进行 Servicebus 触发器

问题描述 投票:0回答:2

我收到错误“函数‘Functions.functionname’的监听器无法启动。”用于在 Azure Functions 云中部署后的 ServiceBus 触发功能。请帮忙解决这个问题。

提前致谢

安尼什

此问题未出现在本地环境中。对于之前创建的其他函数来说,这个问题不会出现。

node.js azure-functions azure-servicebus-queues
2个回答
1
投票
 Retrying to start listener for function 'Functions.cancelOrder'
 (Attempt 383) 2023-06-05T02:16:11Z [Error] The listener for function'Functions.cancelOrder' was unable to start

这是当您的本地函数未连接到 Azure 存储帐户时发生的常见错误,或者如果您正在进行本地开发并且不想使用 Azure 存储帐户,则需要在后台运行 Azure 存储模拟器。另外,如果您没有连接到正确的服务总线命名空间。

我尝试创建一个示例 Azure 服务总线功能应用程序,并且已成功创建。

1) 使用 Azure 存储帐户和服务总线连接字符串:-

我创建了一个服务总线命名空间和一个队列,如下所示:-

enter image description here

创建了一个 Azure 存储帐户:-

enter image description here

按照以下步骤创建 Azure Functions 服务总线队列触发器:-

选择从 VS 代码创建函数 Azure 函数扩展:-

enter image description here

选择 Javascript 作为语言:-

enter image description here

型号 v3:-

enter image description here

Azure 服务总线队列触发器:-

enter image description here

创建本地设置以连接到服务总线:-

enter image description here

选定的服务总线命名空间如下所示:-

enter image description here

输入我之前在服务总线中创建的队列名称,以便我的函数连接到它:-

enter image description here

Azure 服务总线功能是在本地创建的,如下所示:-

enter image description here

现在,当我通过单击 fn + f5运行 > 开始调试 运行此函数时,它将提示我连接到 Azure 存储帐户或使用本地存储模拟器:-

enter image description here

现在,我将单击“连接存储帐户”并选择我的 Azure 存储帐户,如下所示:-

enter image description here

因为,我在 VS code 中安装了 Azure Function Core 工具和 Azure Function 扩展,该函数运行成功,请参阅以下内容:-

enter image description here

现在,我将消息发送到 Azure 服务总线队列并触发了该功能:-

enter image description here

enter image description here

我的 local.settings.json:-

{

"IsEncrypted": false,

"Values": {

 "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=azurestrgaccount;AccountKey=xxxxxxxxOxS+ASt1bDRzw==;EndpointSuffix=core.windows.net",

 "FUNCTIONS_WORKER_RUNTIME": "node",

 "siliconfunc12_SERVICEBUS": "Endpoint=sb://siliconfunc12.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xxxxx5yHisbsUxxxxx"

 }

}

我在Azure Function app中部署了上述Function,部署成功,参考如下:-

enter image description here

enter image description here

功能部署成功,如下:-

enter image description here

enter image description here

2)通过使用本地存储模拟器:-

您可以从此链接在本地计算机中下载存储模拟器。

在启动从上面的链接下载的本地模拟器后,运行我使用本地模拟器的功能时,我按照与上面相同的步骤操作:-

打开模拟器如下:-

enter image description here

模拟器已启动:-

enter image description here

现在,我选择了本地模拟器,功能已成功触发,参考如下:-

enter image description here

enter image description here

enter image description here

我的 local.settings.json:-

{

"IsEncrypted": false,

"Values": {

 "AzureWebJobsStorage": "UseDevelopmentStorage=true",

 "FUNCTIONS_WORKER_RUNTIME": "node",

 "siliconfunc12_SERVICEBUS": "Endpoint=sb://siliconfunc12.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xxxxxHisbsUxp47+ASbMxxxx"

 }

}

我尝试在Azure Function应用程序中部署此功能,它也成功了:-

enter image description here

如果错误仍然存在,请确保从此路径 C\Program Files\Microsoft\Azure Functions Core Tools 中删除现有的 Azure Functions Core 工具。并通过参考此链接安装较新版本的Azure Function核心工具。

我的 Azure Functions 核心工具版本:-

func -v
4.0.5148

enter image description here

Node.js 版本:-

node -v
v18.16.0

存储模拟器版本:-

5.10.0.0

enter image description here

除此之外,请确保您的 VS Code 中安装了以下扩展:-

enter image description here

enter image description here

确保您还安装了 Azurite 扩展:-

enter image description here

参考资料:-

python - 函数“Functions.trigger”的监听器无法启动?在本地运行 Azure 函数时 - Stack Overflow 作者:venkateshdodda

本地运行 Azure 函数应用程序时,Azure 函数的侦听器无法启动错误。怎么解决这个问题呢? - 微软问答 作者:MayankBargali-MSFT


0
投票

@SiddeshDesai 的答案可以修复与侦听器相关的错误。但是,如果您使用的是 Mac,则无法安装 Azure 存储模拟器。您需要使用基于节点的 Azurite 模拟器进行本地 Azure 存储开发,它提供相同的功能。更多信息请参见:https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=visual-studio%2Cblob-storage

需要本地运行存储模拟器来修复侦听器错误。

© www.soinside.com 2019 - 2024. All rights reserved.