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.
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