我使用具有天蓝色功能的服务总线。该函数由队列触发,然后输入BrokeredMessage上的ReplyTo属性将用作响应队列。如何动态绑定到输出队列?我已尝试过以下代码,但获得:
无法绑定ServiceBus以进行输入 ' Microsoft.ServiceBus.Messaging.BrokeredMessage'
public static async Task Run(BrokeredMessage msg, Binder binder, TraceWriter log)
{
log.Info($"C# ServiceBus queue trigger function processed message");
var msgout = await binder.BindAsync<BrokeredMessage>(new ServiceBusAttribute(msg.ReplyTo));
}
function.json
{
"disabled": false,
"bindings": [
{
"name": "msg",
"type": "serviceBusTrigger",
"direction": "in",
"queueName": "myInputQueue",
"connection": "AzureWebJobsServiceBus",
"accessRights": "Manage"
}
]
}
答案 0 :(得分:3)
对于输出方案,您需要绑定到 IAsyncCollector 类型:
public static async Task Run(
BrokeredMessage msg, Binder binder, TraceWriter log)
{
log.Info($"C# ServiceBus queue trigger function processed message");
var collector = await binder.BindAsync<IAsyncCollector<BrokeredMessage>>(
new ServiceBusAttribute(msg.ReplyTo));
var message = ...
await collector.AddAsync(message);
}