7

What is the best way to use F# in Azure Functions at the moment? I want my function to have both input and output bindings (e.g. to queues or event hubs)

What I found so far:

Is there a way to take an F# function with inputs and output and host it as a Azure Function directly? Something similar to C# Run method?

Ideally, inputs and outputs should be strongly typed: an object, record or discriminated union.

Community
  • 1
  • 1
Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107

2 Answers2

6

The templates are only meant to be starting points - you can add additional input/output bindings to them easily in the portal "Integrate" tab. For example, if you add a new Blob output named result and bound to blob path "test-output/%rand-guid%", you can write script like the below that writes a blob:

open System
open System.IO

let inputPath = Environment.GetEnvironmentVariable("input")
let input = File.ReadAllText(inputPath)
let message = sprintf "F# script processed queue message '%s'" input
System.Console.Out.WriteLine(message)

let resultPath = Environment.GetEnvironmentVariable("result")
File.WriteAllText(resultPath, input);

Regarding more strongly typed "first class" support for F#, as I mentioned in the forum post you linked to, we're working on it :) For now, F# is in the bucket with all the other out of proc script types, where the communication mechanism in and out of the binding pipeline is via environment variables as you can see above.

mathewc
  • 13,312
  • 2
  • 45
  • 53
6

Now F# is native!

Thanks to the excellent work by the F# team including Don Syme and Tomas Petricek, we're happy to announce we finally support F# in a first-class fashion in Azure Functions.

https://blogs.msdn.microsoft.com/appserviceteam/2016/09/01/azure-functions-0-5-release-august-portal-update/

Johan Karlsson
  • 494
  • 5
  • 7