I'm trying to create a Function that is triggered when a message becomes available in an Azure Service Bus subscription. I followed the brief example from the official docs.
Running the app locally via func host start
leads to the following error: "ServiceBusTriggerJS: The binding type 'serviceBusTrigger' is not registered. Please ensure the type is correct and the binding extension is installed."
My setup:
package.json
contains the azure node module: "azure": "^2.2.1-preview"
. Node version is 8.11.
function.json
is as in the example:
{
"disabled": false,
"bindings": [
{
"topicName": "myTopic",
"subscriptionName": "mySubscription",
"connection": "MyServiceBus",
"name": "myQueueItem",
"type": "serviceBusTrigger",
"direction": "in"
}
]
}
local.settings.json
contains connection strings to the Service Bus and a storage account that is necessary for running locally:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=...",
"MyServiceBus": "Endpoint=sb://...servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=..."
}
}
index.js
is the same as the example, too:
module.exports = function (context, myQueueItem) {
context.log('JavaScript queue trigger function processed work item', myQueueItem);
context.done();
};
EDIT: This is similar to this question: The binding type 'serviceBusTrigger' is not registered error in azure functions c# with core tools 2. The problem (and therefore solution) are the same. I find the answer here straight-forward to implement.
You should install the servicebus extension using
func extensions install --package Microsoft.Azure.WebJobs.ServiceBus --version 3.0.0-beta5
.
The extension is used to register the servicebus trigger, making the trigger recognized by your local function run time. It is like a complement for the run time, so it doesn't matter what language you use.
Everything works on my side(js function), feel free to ask if you have further questions.