Wednesday, August 17, 2011

How to query windows azure diagnostics for a time range?

Windows Azure Diagnostics stores data in Azure Table. Unfortunately, Azure Table only supports a single index, which means queries that don't use the index are dog slow.  In azure terminology, that index is the partition key, and Windows Azure Diagnostics sets the partition key on your behalf using the following formula:     0 + DateTime.Ticks


You can generate the Partition key query in powershell for all logs after 7/15 by doing:

PS C:\> "PartionKey gt '0$((Get-Date '2011/7/15').Ticks)'"
PartionKey gt '0634462848000000000'


For the curious, gt is the greater than operator in Azure Table, which is based on ADO.Net DataServices, which is now called WCF Data Services, which is  OData.

Monday, August 8, 2011

F# and the immediate window

(This post is inspired from this Stack Overflow question)



F# debugger integration is quite good, except for the immediate window. The immediate window requires C# style syntax, so calling F# functions is not intuitive. Below are recipes for the immediate window integrated into a console application. As always code can be found here:

// Learn how to use the immediate window for F#.
module Program=

// To build, add a reference to Microsoft.CSharp. This is required for dynamic support in
// the debugger.
let allowDynamicToWorkFromImmediateWindowByLoadingCSharpBinders = Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags.BinaryOperationLogical

let plusOne = (+)1
let xPlusOnes = [1;2;3] |> Seq.map plusOne

[]
let main (args) =
printfn "Try the following in the immediate window:
// plusOne 4
((dynamic)plusOne).Invoke(4)

// Seq.Head xPlusOnes
Microsoft.FSharp.Collections.SeqModule.Head(xPlusOnes)

// let xPlusTwos= xPlusOnes |> Seq.map plusOne
// Seq.Head xPlusTwos
var xPlusTwos = Microsoft.FSharp.Collections.SeqModule.Map(plusOne,xPlusOnes);
Microsoft.FSharp.Collections.SeqModule.Head(xPlusTwos)"

System.Diagnostics.Debugger.Break()
let returnValue = 1
returnValue