The Azure Function dotnet class library docs detail how to use an IBinder to connect to any storage endpoint.
How to late bind to a Queue?
The example given shows binding to a Blob container as a TextWriter.
[FunctionName("CreateBlobUsingBinder")]
public static void Run(
[QueueTrigger("myqueue-items-source-4")] string myQueueItem,
IBinder binder,
ILogger log)
{
log.LogInformation($"CreateBlobUsingBinder function processed: {myQueueItem}");
using (var writer = binder.Bind<TextWriter>(new BlobAttribute(
$"samples-output/{myQueueItem}", FileAccess.Write)))
{
writer.Write("Hello World!");
};
}
In the 'Attribute' syntax it would be:
[QueueTrigger("inputQ")] InputDTO inputobject,
[Queue("output{clientid}Q")] OutputDTO outputobject,
IBinder binder{
...
}
but in my situation 'clientid' is not known until after binding occours.
Solution is to use an ICollector<T>
.
var clientid = inputclientid;
var practiceMessageQueue = await binder.BindAsync<ICollector<OutputDTO>>(
new QueueAttribute($"output{clientid}Q")).ConfigureAwait(false);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.