我想在我的Azure函数中使用输出队列。我从下面得到一个示例代码:
https://docs.microsoft.com/en-us/sandbox/functions-recipes/queue-storage
[FunctionName("BasicQueueOutput")]
public static void Run([TimerTrigger("*/30 * * * * *")]TimerInfo myTimer,
TraceWriter log,
[Queue("101functionsqueue",Connection = "AzureWebJobsStorage")] out string queueMessage)
{
log.Info("101 Azure Function Demo - Storage Queue output");
queueMessage = DateTime.UtcNow.ToString();
}
它对sync方法很好,但在我的例子中它是异步方法:
[FunctionName("FunctionRegisterDomain")]
public async static Task Run(
[QueueTrigger("domain-registation", Connection = "StorageConnectionString")]DomainForRegistration queueItem,
[Queue("domain-add-to-office365", Connection = "StorageConnectionString")]out DomainForRegistration outputQueue,
ILogger log)
我得到一个错误:
异步方法不能有ref、in或out参数
当然,我可以做到:
[Queue("domain-add-to-office365", Connection = "StorageConnectionString")]CloudQueue outputQueue,
然后使用它:
await outputQueue.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject(queueItem)));
但我想使用到队列消息的绑定来完成这项工作