Convert C# HostBuilder pipeline to F# in isolated process Azure function

Viewed 169
1 Answers

As far as translating C# to F#, the code would look something like this:

open Microsoft.Extensions.Hosting
open Microsoft.Extensions.DependencyInjection
open Microsoft.Azure.Functions.Worker.Configuration

let host =
    HostBuilder()
        .ConfigureFunctionsWorkerDefaults()
        .ConfigureServices(fun s ->
            s.AddSingleton<IHttpResponderService, DefaultHttpResponderService>()
        )
        .Build()

task {
    do! host.RunAsync()
} |> ignore

I'm unfamiliar with Azure Functions, so I don't know if RunAsync() should be something that's just ignore or something else. The docs don't make it clear, so I chose to ignore it.

Related