2
votes

I'm trying to add a message to an azure message queue from an azure function. To do so, I'm following this article where it has me add a reference to Microsoft.Azure.ServiceBus.

https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-dotnet-get-started-with-queues

When trying to add this reference, the Azure function project in Visual Studio 2017 complains about the restricted version of Newtonsoft.Json (=9.0.1) relative to the Microsoft.NET.Sdk.Functions reference.

Version conflict detected for Newtonsoft.Json. Install/reference Newtonsoft.Json 10.0.1 directly to project IHA.Functions to resolve this issue. IHA.Functions -> Microsoft.Azure.ServiceBus 3.1.0 -> System.IdentityModel.Tokens.Jwt 5.2.2 -> Newtonsoft.Json (>= 10.0.1)
IHA.Functions -> Microsoft.NET.Sdk.Functions 1.0.14 -> Newtonsoft.Json (= 9.0.1). IHA.Functions C:\TFS\IHA\Misc\IHA.CSL\IHA.Functions\IHA.Functions.csproj 1

From what I understand, Microsoft.Azure.ServiceBus requires Newtonsoft.Json 10.0.1. If I remove the 9.0 version and add the 10.0 version, I can successfully add the Microsoft.Azure.ServiceBus package, but then the Azure Functions project complains that Microsoft.NET.Sdk.Functions requires 9.0 of Newtonsoft.

Based on these understandings, I can't seem to write to an Azure message queue from an Azure function. Is this correct or am I doing something wrong?

1

1 Answers

6
votes

Azure Functions have explicit support for Service Bus in the form of extension.

You need to install the extension, see Azure Service Bus bindings for Azure Functions. Pay attention which Function App version you are using: 1.x with full .NET Framework, or beta 2.x with .NET Standard, and follow the corresponding guidance.

Then, instead of using Service Bus SDK directly, you would define and write to an output binding.