Skip to content

Instantly share code, notes, and snippets.

@isaacabraham
Last active January 6, 2017 15:04
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save isaacabraham/601d058df22ac6c26c64 to your computer and use it in GitHub Desktop.
Save isaacabraham/601d058df22ac6c26c64 to your computer and use it in GitHub Desktop.
Hosting Suave in Azure Service Fabric
open Microsoft.ServiceFabric.Services
open Suave
open Suave.Http.Successful
open Suave.Web
open System.Fabric
open System.Threading
open System.Threading.Tasks
type SuaveService() =
inherit StatelessService()
override __.CreateCommunicationListener() =
{ new ICommunicationListener with
member __.Abort() = ()
member __.CloseAsync _ = Task.FromResult() :> Task // should close down gracefully
member __.Initialize _ = () // any initialization goes here
member __.OpenAsync cancellationToken =
async {
let starting, server = startWebServerAsync defaultConfig (OK "Hello from Service Fabric!")
Async.Start(server, cancellationToken)
do! starting |> Async.Ignore
return (defaultConfig.bindings.Head.ToString())
} |> Async.StartAsTask
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment