英文:
Getting error "The listener for function 'Functions.functionname' was unable to start." for Servicebus trigger using node.js
问题
我在将函数部署到Azure函数云后,出现错误:“函数 'Functions.functionname' 的监听器无法启动。” 请帮助解决此问题。
提前致谢
Anish
在本地环境中没有出现此问题。而且早期创建的其他函数也没有出现此问题。
英文:
I am getting error "The listener for function 'Functions.functionname' was unable to start." for ServiceBus trigger function after deploying in azure functions cloud. Please help to resolve this.
Thanks in advance
Anish
This issue is not getting in local environment. And this issue not getting for other functions created earlier.
答案1
得分: 0
重试启动函数'Functions.cancelOrder'的侦听器
(尝试 383) 2023-06-05T02:16:11Z [错误] 函数'Functions.cancelOrder'的侦听器无法启动
这是一个常见错误,当您的本地函数未连接到 Azure 存储帐户,或者如果您正在进行本地开发并且不想使用 Azure 存储帐户,则需要在后台运行 Azure 存储仿真器。另外,如果您未连接到正确的服务总线命名空间。
我尝试创建一个示例的 Azure 服务总线函数应用,并且它成功创建了。
1) 使用 Azure 存储帐户和服务总线连接字符串:
我创建了一个服务总线命名空间和一个队列如下所示:
创建了一个 Azure 存储帐户:
按照以下步骤创建 Azure Functions 服务总线队列触发器:
从 VS Code Azure Function 扩展中选择创建函数:
选择 JavaScript 作为语言:
选择模型 v3:
Azure 服务总线队列触发器:
创建本地设置以连接到服务总线:
选择服务总线命名空间如下所示:
输入我之前在我的服务总线中创建的队列名称,以便我的函数连接到它:
Azure 服务总线函数在本地创建如下所示:
现在,当我通过单击 fn + f5 或 Run > Start Debugging 运行此函数时,它会提示我要么连接到 Azure 存储帐户,要么使用本地存储仿真器:
暂时我将点击连接存储帐户,并选择我的 Azure 存储帐户如下所示:
由于我在 VS Code 中安装了 Azure Function Core 工具和 Azure Function 扩展,该函数成功运行,如下所示:
现在,我将消息发送到 Azure 服务总线队列,函数将被触发:
我的 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 应用程序,部署成功,如下所示:
函数成功部署,如下所示:
2) 使用本地存储仿真器:
您可以从此链接在本地计算机上下载存储仿真器。
我按照以上相同的步骤操作,只是在运行函数时,我在从上面链接下载的本地仿真器启动后使用了本地仿真器:
如下图所示打开仿真器:
仿真器已启动:
现在,我选择了本地仿真器,函数成功触发,如下所示:
我的 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 应用程序,也成功了:
如果错误仍然存在,请确保您删除了此路径中的现有 Azure Functions Core 工具 - C\Program Files\Microsoft\Azure Functions Core Tools,并通过参考此链接安装 Azure Function 核心工具的新版本。
我的 Azure Functions Core 工具版本:
func -v
4.0.5148
![输入图像描述](https://i
英文:
> 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
This is a common error that occurs when your Local Function is not connected to either Azure Storage account or if you are doing a local development and do not want to use Azure storage account you need to have Azure storage emulator running in the background. Also, if you're not connected to correct Service bus namespace.
I tried creating one sample Azure Service bus Function app and it was created successfully.
1) With Azure Storage Account and Service bus connection string:-
I created one Service Bus namespace and one queue like below:-
Created one Azure Storage account:-
Followed the steps below to create Azure Functions Service bus queue trigger:-
Selected create Function from VS code Azure Function extension:-
Selected Javascript as language:-
Model v3:-
Azure Service Bus Queue Trigger:-
Created local settings to connect to Service bus:-
Selected Service Bus Namespace like below:-
Entered the queue name I created earlier in my service bus for my function to connect to it:-
The Azure Service Bus Function is created Locally like below:-
Now, When I run this Function by either clicking on fn + f5 or Run > Start Debugging It will prompt me to either connect to Azure storage account or use Local storage emulator:-
For now I will click on Connect Storage account and select my Azure storage account like below:-
As, I have Azure Function Core tools and Azure Function extension installed in VS code, The Function ran successfully, Refer below:-
Now, I sent messages to Azure Service Bus queue and the Function was triggered:-
My 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"
}
}
I deployed the above Function in Azure Function app and the deployment was successful, Refer below:-
Function got deployed successfully, Refer below:-
2) By using Local storage emulator:-
You can download the Storage Emulator in your local machine from this Link.
I followed the same steps as above just while running the function I used Local Emulator after starting the Local Emulator downloaded from the link above:-
Opened Emulator like below:-
Emulator started:-
Now, I selected Local Emulator and the Function was triggered successfully, Refer below:-
My 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"
}
}
I tried deploying this Function in Azure Function app and it was successful too:-
If the error persists, Make sure you delete the existing Azure Functions Core tools from this path - C\Program Files\Microsoft\Azure Functions Core Tools. and install the newer version of Azure Function core tools by referring this Link.
My Azure Functions Core tools version:-
func -v
4.0.5148
Node.js version:-
node -v
v18.16.0
Storage emulator version:-
5.10.0.0
Along with this Make sure you have below extensions installed in your VS Code:-
Make sure you also have Azurite extenstion installed:-
References:-
python - The listener for function 'Functions.trigger' was unable to start? while running Azure function locally - Stack Overflow By venkateshdodda
Listener for Azure function was unable to start error while running Azure function app locally. How to solve this? - Microsoft Q&A By MayankBargali-MSFT
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论