7
votes

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!

5

5 Answers

17
votes

You need to include the Microsoft.Azure.WebJobs.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

6
votes

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.

4
votes

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

0
votes

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.

0
votes

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