Reputation: 169
I'm using the Node.js v4 programming model for Azure Functions, and I have a Service Bus-triggered function with the following setup:
app.serviceBusQueue('MyFunctionName', {
queueName: 'myQueueName',
connection: 'ServiceBusConnectionString',
handler: azureFunction,
isSessionsEnabled: true,
});
Host.json:
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.0.0, 5.0.0)"
},
"functionTimeout": "00:04:00",
"extensions": {
"serviceBus": {
"prefetchCount": 10,
"messageHandlerOptions": {
"maxConcurrentCalls": 16,
"autoComplete": true,
"maxAutoRenewDuration": "00:05:00"
}
}
}
}
Node.js runtime version: 18
Works locally with func start, but messages aren't processed when deployed to Azure portal.
I've verified that:
UPDATE: checking insights I could see the error
The 'MyFunctionName' function is in error: The binding type(s) 'serviceBusTrigger' are not registered. Please ensure the type is correct and the binding extension is installed.
Upvotes: 0
Views: 93
Reputation: 169
So, after a few hours, I finally discovered what the problem was:
I have a monorepo from which I deploy different function apps. The issue was that the host.json
file were not located in the root directory of the function app after deployment.
To check this I went to:
https://<functionAppName>.scm.azurewebsites.net/DebugConsole
Then into site
and then wwwroot
folder.
Ensure that host.json
is there and it is well configured. If it is missing or incorrectly configured, the Azure Functions runtime may not recognize extensions.
Upvotes: 0
Reputation: 6497
I have used the given code and have followed below steps to achieve it.
import { app, InvocationContext } from "@azure/functions";
export async function serviceBusQueueTrigger1(message: unknown, context: InvocationContext): Promise<void> {
context.log('Service bus queue function processed message:', message);
}
app.serviceBusQueue('serviceBusQueueTrigger1', {
connection: 'ServiceBusConnectionString',
queueName: 'myqueue',
handler: serviceBusQueueTrigger1,
isSessionsEnabled: true
});
Post deployment, I fetched connection string and added in Environment variable as shown below.
Function got triggered upon sending a message in service bus queue.
If it still doesn't fires then check the associated application insight in case of any errors.
Upvotes: 1