azure-functions-fsharp-examples
azure-functions-fsharp-examples copied to clipboard
V3 Return style attributes
This was an excellent aid to writing functions - things have moved on.
For ServiceBus outputs the new preferred method is to use a return type binding as per
https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus-output?tabs=csharp
[<FunctionName("my_V3_functiony")>]
let ``sBus In and Sbus Out``
(executionContext: ExecutionContext, log: ILogger,
[<ServiceBusTrigger("inQueue", Connection = "InQueueSetting")>] message: string)
: [<return: ServiceBus("outTopic", ServiceBus.EntityType.Topic, Connection = "outTopicSetting")>] string =
message
|> ``domain Function That Return Output Message As String``
Note - Fantomas messes up the return attribute.
@sadgit if you also want to do more complex things in the function body (for instance respond to an HTTP request), you can also use the IAsyncCollector class. See example in the PR here https://github.com/mikhailshilkov/azure-functions-fsharp-examples/pull/5
I have been having some issues with the Microsoft.Azure.ServiceBus 4.1.3 - which is happy with the return Attribute but didn't want to respect old style (v2) Async Collector. This also causes complication of HTTP triggers and multiple output Queues. Our codebase is fine - but I wanted to keep these examples current as I found them useful.