azure-functions-host: Can't use Task anymore

The following F# code doesn’t work anymore with latest 2.0.11933.0 (beta) runtime:

module SendEMail

open Microsoft.Azure.WebJobs
open FSharp.Control.Tasks.ContextInsensitive
open System.IO

[<FunctionName("SendEMail")>]
let Run([<QueueTrigger("sendmail")>] content:string, log: Host.TraceWriter) = task {
    log.Info(sprintf "Got message %A" mail)        
}

This is basically returning a System.Threading.Tasks.Task<unit> to the runtime. This used to work in older runtime versions. Now we need to explicitly await this task.

Function (SendEMail) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.SendEMail'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter '$return' to type Unit&. 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.).

Session Id: dd084db993414b2ba3d9e7eea6e73848

Timestamp: 2018-07-24T07:34:08.549Z Region: Europe West FunctionApp: ecarjobs

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (21 by maintainers)

Most upvoted comments

Well all APIs between (left out in the sample) are task based. So I’d manually await all of them separately. With the proposed workaround I only have to do it once.