首页 > 解决方案 > Microsoft.Azure.WebJobs.Host:无法将参数“$return”绑定到布尔类型

问题描述

我该如何解决 ?:/

public static async Task<bool> Run([QueueTrigger("<queueNameHere", Connection = "<connectionHere>")]byte[] myQueueItem, TraceWriter log)

导致错误:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Run'. 
Microsoft.Azure.WebJobs.Host: Cannot bind parameter '$return' to type
Boolean&. Make sure the parameter Type is supported by the binding. If
you're using binding extensions (e.g. ServiceBus, Timers, etc.) make
sure you've called the registration method for the extension(s) in
your startup code (e.g. config.UseServiceBus(), config.UseTimers(),
etc.).

标签: azure-webjobs

解决方案


该错误源于您试图将返回类型设置为布尔(任务),我相信 QueueTriggered 函数只能具有 void 返回类型。所以只需删除返回类型:

public static async Task Run(...)

您尝试返回类型是否有特定目的?如果您尝试将状态传达给另一个进程,那么您应该考虑另一种方法,例如通过输出绑定将完成的消息放在另一个队列中或更新数据库中的状态等。


推荐阅读