Windows Azure finally has a good F# support. Creating F# Worker Roles is supported right from the wizzard in Visual Studio and you can create a F# Web Role using the F# C# MVC template. I decided to try it out and the first thing I needed to implement was logging. I decided for logging to Azure Table Storage.
I assume you have a basic idea of how Azure Table Storage works. If not, there is a good guide on the Windows Azure website.
The first thing you need to do is to define your log entry class. You need to create a class, Azure Table Storage does not work with F# records. In my case I want to store a timestamp, message and severity.
[<DataServiceKey("PartitionKey", "RowKey")>] type LogEntity() = let mutable partitionKey = "" let mutable rowKey = "" let mutable message = "" let mutable timestamp = DateTime.Now let mutable severity = "" member x.PartitionKey with get() = partitionKey and set v = partitionKey <- v member x.RowKey with get() = rowKey and set v = rowKey <- v member x.Message with get() = message and set v = message <- v member x.Timestamp with get() = timestamp and set v = timestamp <- v member x.Severity with get() = severity and set v = severity <- v