7

The "How to use Azure Service Bus with the WebJobs SDK" Azure Documentation article shows the usage of [ServiceBusTrigger] attribute for integrating a WebJob and Azure Service Bus Topic messages. However, using the default Azure WebJobs project template in Visual Studio 2015, the reference to ServiceBusTrigger causes the following compile time exception:

The type or namespace name 'ServiceBusTriggger' could not be found (are you missing a using directive or an assembly reference?)

The problem at hand is the Microsoft.Azure.WebJobs package from Nuget doesn't contain the ServiceBusTriggerAttribute class.

Is there a Nuget package that can be added that will include this much needed class?

I have tried including the WindowsAzure.ServiceBus package from Nuget, but that doesn't contain it either.

Without the ServiceBusTriggerAttribute I am unable to get this WebJob connected to consume messages from an Azure Service Bus Topic. Any help would be greatly appreciated! Thanks!

Chris Pietschmann
  • 29,502
  • 35
  • 121
  • 166

5 Answers5

18

You need to include the Microsoft.Azure.WebJobs.Extensions.ServiceBus NuGet package as mentioned in the Prereq section of this article https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-webjobs-sdk-service-bus/#prerequisites

Community
  • 1
  • 1
pranav rastogi
  • 4,124
  • 23
  • 23
7

This answer is correct for Functions 1.x, but if you are using Functions 2.x, then you need to install Microsoft.Azure.WebJobs.Extensions.ServiceBus:

Install-Package Microsoft.Azure.WebJobs.Extensions.ServiceBus

Here is the Microsoft documentation Azure Service Bus bindings for Azure Functions.

Also, make sure you reference the latest package and update any dependent packages.

Rogala
  • 2,679
  • 25
  • 27
4

The Microsoft.Azure.WebJobs.ServiceBus package from Nuget contains the ServiceBusTriggerAttribute class.

Chris Pietschmann
  • 29,502
  • 35
  • 121
  • 166
0

My trouble was that I had a project of type Azure Functions v2 Preview which uses .NET standard instead of the .NET Framework.

Creating a new project of the old v1 type and importing Microsoft.Azure.WebJobs.ServiceBus via NuGet got me on my way.

Taran
  • 12,822
  • 3
  • 43
  • 47
0

For Azure Functions v2 Preview (.NET Standard 2.0), you need to install the prerelease version of Microsoft.Azure.WebJobs.ServiceBus:

Install-Package Microsoft.Azure.WebJobs.ServiceBus -IncludePrerelease

Or via NuGet Package Manager:

NuGet Package Manager screen

Alisson Reinaldo Silva
  • 10,009
  • 5
  • 65
  • 83