Skip to content

Instantly share code, notes, and snippets.

@filipw filipw/gist:9846071

Last active May 3, 2016
What would you like to do?
ASP.NET Web API hosted in Azure Worker Role with OWIN in F#
namespace WebApi.AzureWorker
open Owin
open System
open System.Diagnostics
open System.Net
open System.Threading
open System.Net.Http
open System.Web.Http
open Microsoft.Owin.Hosting
open Microsoft.WindowsAzure.ServiceRuntime
type TestController() =
inherit ApiController()
member x.Get() = "Hello Azure!"
type WorkerRole() =
inherit RoleEntryPoint()
let mutable webApp = None
override w.Run() =
while(true) do
Trace.TraceInformation("Working", "Information")
override w.OnStart() =
ServicePointManager.DefaultConnectionLimit <- 12
let endpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints.["Default"]
let uri = sprintf "%s://%O" endpoint.Protocol endpoint.IPEndpoint
webApp <- Some(WebApp.Start(uri, fun app ->
let config = new HttpConfiguration()
app.UseWebApi(config) |> ignore
override w.OnStop() =
match webApp with
| Some x -> x.Dispose() |> ignore
| None -> ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.