【问题标题】:Writing message to Azure Service Bus queue from Azure function从 Azure 函数将消息写入 Azure 服务总线队列
【发布时间】:2019-01-23 14:45:08
【问题描述】:

我正在尝试从 azure 函数将消息添加到 azure 消息队列。为此,我正在关注这篇文章,它让我添加了对 Microsoft.Azure.ServiceBus 的引用。

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

尝试添加此引用时,Visual Studio 2017 中的 Azure 函数项目抱怨 Newtonsoft.Json (=9.0.1) 相对于 Microsoft.NET.Sdk.Functions 引用的受限版本。

检测到 Newtonsoft.Json 的版本冲突。安装/参考 Newtonsoft.Json 10.0.1 直接到project IHA.Functions来解决 这个问题。 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\IH​​A.Functions\IHA.Functions.csproj 1

据我了解,Microsoft.Azure.ServiceBus 需要 Newtonsoft.Json 10.0.1。如果我删除9.0版本并添加10.0版本,我可以成功添加Microsoft.Azure.ServiceBus包,但是Azure Functions项目抱怨Microsoft.NET.Sdk.Functions需要Newtonsoft 9.0。

基于这些理解,我似乎无法从 Azure 函数写入 Azure 消息队列。这是正确的还是我做错了什么?

【问题讨论】:

    标签: azure-functions azureservicebus


    【解决方案1】:

    Azure Functions 以扩展的形式明确支持服务总线。

    您需要安装扩展程序,请参阅Azure Service Bus bindings for Azure Functions。请注意您使用的是哪个 Function App 版本:完整的 .NET Framework 1.x,或 .NET Standard 的 beta 2.x,并遵循相应的指导。

    然后,您将定义并写入 output binding,而不是直接使用 Service Bus SDK。

    【讨论】:

    • 谢谢!效果很好,我编辑了标题。感谢您的帮助!
    • python sdk 是否支持服务总线的输出绑定?已经找了一段时间了,在这上面找不到任何东西
    • 值得一个单独的问题来给出更大的答案,但是yes
    猜你喜欢
    • 1970-01-01
    • 2014-11-03
    • 2017-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-28
    • 1970-01-01
    相关资源
    最近更新 更多