0

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:

  • The connection string is correctly set in Azure's Application Settings (without EntityPath).
  • The runtime version in both local and Azure portal is v4.
  • The Function App is running and not in a stopped state.
  • The queue name and connection match the function definition.

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.
4
  • Can you share your complete function code? Also, are you using manage type connection string? Commented Oct 10, 2024 at 10:07
  • Is it a javascript or typescript function? @DavideBracaglia Commented Oct 10, 2024 at 10:25
  • @IkhtesamAfrin, it is typescript function and I am using Listen type connectionstring. I tested to change to Manage but still not firing the function. Commented Oct 10, 2024 at 10:30
  • Please share the screenshot of the environment variable where you have added the connection string @DavideBracaglia Commented Oct 10, 2024 at 10:51

2 Answers 2

1

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.

enter image description here

enter image description here

Function got triggered upon sending a message in service bus queue.

enter image description here

If it still doesn't fires then check the associated application insight in case of any errors.

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the answer. Looking at insights I could see this 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.
@DavideBracaglia please share your complete function code
I tested with same sample code you provieded :) It works locally but not on portal. I was wondering if it has something to do with the fact that we use monorepo. In package.json of the specific project we have @azure/service-bus in dependencies. And if I check the location of service-bus I can see: ├─┬ @edge/[email protected] -> ./apps/b2b │ └── @azure/[email protected] └─┬ @edge/[email protected] -> ./apps/edge └── @azure/[email protected] deduped I use servicebustrigger in edge project.
Did you check the app insights for any errors?
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.