3

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.

5
  • @JerryLiu: It's similar, but not a duplicate, because the framework here is Node/JS, whereas in your linked question it is NET/C#. Commented Apr 25, 2018 at 3:24
  • Sorry for lack of explanation. Language doesn't matter. I will write a complete answer for your to refer. Commented Apr 25, 2018 at 5:20
  • Oh, I misinterpreted your comment indeed. And now I reread the official documentation. Indeed, I had not installed the bindings. But it still doesn't work. More details in a comment to your answer. Commented Apr 25, 2018 at 14:57
  • What version of the Functions core tools did you install? What host version do you see when you run func host start? Commented Apr 26, 2018 at 18:21
  • @brettsam: I did some installing and uninstalling. Now when everything is working I have: tools version = 220.0.0-beta.0, runtime version = 2.0.11651, Commented Apr 27, 2018 at 14:29

2 Answers 2

3

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.

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

4 Comments

I just tried that, and it didn't work. The installation itself says the build is successful. Since I'm running Azure Functions v1, I also tried ServiceBus version 2.2. Same result: installation says it's successful, but func host start still complains with the same error message.
There was another issue: When installing the extension. NuGet looks at the global package repo list. In my case this included company-internal repos, which it couldn't auth into. So instead of checking the other repos, the installer gave up. It did produce error messages, but had I ignored them because I had thought it would figure it out on its own. Especially since it had said that the build was successful. To resolve, I opened Visual Studio and unchecked all repos but the official nuget feed and then installed the extension again. I accept your answer because that is the main solution.
Thanks a lot for your explanation! I thought you were using function v2 so I said it's a duplicate question. It's my mistake that forget to ask your runtime version. Usually v1 doesn't need to register servicebus manually, the core tool contains the extension originally. It may also be related to your internal repos issue. Anyway, glad you solved it and also thanks for accepting my negligible answer.
This command is giving me error
1

This is what I did to Build an Azure function service bus queue trigger (in Node.Js) on CI/CD pipeline in Azure DevOps: Before adding this to steps below after deploying the function to azure I got serviceBusTrigger is not registered error:

- script: 'func extensions install --package Microsoft.Azure.WebJobs.ServiceBus --version 3.0.0-beta8'
   displayName: 'install servicebus extension'

- script: 'func extensions install --package Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator --version 1.0.1'
  displayName: 'install azure WebJobs ExtensionsMetadataGenerator'


But after adding those steps as you see below, it works fine. I used this YAML on Azure DevOps Build pipeline and it worked for me:

pool:
  vmImage: windows-2019
  demands: npm

steps:
- script: 'func extensions install --package Microsoft.Azure.WebJobs.ServiceBus --version 3.0.0-beta8'
   displayName: 'install servicebus extension'

- script: 'func extensions install --package Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator --version 1.0.1'
  displayName: 'install azure WebJobs ExtensionsMetadataGenerator'

- task: NodeTool@0
  inputs:
    versionSpec: '10.x'

- task: Npm@1
  displayName: 'npm install'
  inputs:
    command: install

- task: Npm@1
  displayName: 'npm az core tools'
  inputs:
    command: custom
    verbose: false
    customCommand: 'i -g azure-functions-core-tools@core --unsafe-perm t'

- task: PublishTestResults@2
  inputs:
    testResultsFiles: '**/TEST-RESULTS.xml'
    testRunTitle: 'Test results for JavaScript'
  condition: succeededOrFailed()

- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
    includeRootFolder: false
    archiveFile: "$(System.DefaultWorkingDirectory)/FunctionApp.zip"

- task: CopyFiles@2
  inputs:
    SourceFolder: '$(System.DefaultWorkingDirectory)'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: "$(Build.ArtifactStagingDirectory)"
    ArtifactName: "drop"

2 Comments

For a useful answer explain in more detail why this is an answer to the question.
I added more description.

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.