[英]Output multiple Brokered Messages to an Azure Service Bus Topic(s) with Azure Functions
Is there a way you output multiple Brokered Messages to an Azure Service Bus in Azure Functions? 有没有一种方法可以将多个代理消息输出到Azure Functions中的Azure服务总线? by default you can output a single Brokered Message but not multiple.
默认情况下,您只能输出一个代理消息,但不能输出多个。
Currently using the SDK to do this but wondered if there is a way you can do this using the output... 当前使用SDK执行此操作,但想知道是否可以使用输出来执行此操作...
Thanks 谢谢
As per the documentation on ServiceBus output bindings: 根据有关ServiceBus输出绑定的文档:
For creating multiple messages in a C# function, you can use ICollector<T>
or IAsyncCollector<T>
. 要在C#函数中创建多个消息,可以使用
ICollector<T>
或IAsyncCollector<T>
。 A message is created when you call the Add method. 当您调用Add方法时,将创建一条消息。
Here is a simple example of using ICollector (also directly from the docs): 这是一个使用ICollector的简单示例(也直接来自文档):
public static void Run(TimerInfo myTimer, TraceWriter log, ICollector<string> outputSbQueue)
{
string message = $"Service Bus queue message created at: {DateTime.Now}";
log.Info(message);
outputSbQueue.Add("1 " + message);
outputSbQueue.Add("2 " + message);
}
I personally find that all of the supported input/output bindings are well documented and examples are readily available at the link I've shown here. 我个人发现,所有受支持的输入/输出绑定都有详细的文档说明,并且在我在此处显示的链接中可以轻松找到示例。 Just pick the appropriate binding you're working with (if it's something other than Service Bus)
只需选择您正在使用的适当绑定(如果不是Service Bus,则选择其他绑定)
Also, Functions is built on top of the WebJobs SDK; 此外,Functions是在WebJobs SDK的基础上构建的; so if you can do a binding in the SDK, you can do the same thing in Functions (with a few corner case exceptions).
因此,如果您可以在SDK中进行绑定,则可以在“函数”中执行相同的操作(有一些例外情况)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.