Skip to content

Instantly share code, notes, and snippets.

@Thorium
Created September 15, 2025 08:44
Show Gist options
  • Save Thorium/a5bfb0e1b118b0a7a3ff211da0df8ba3 to your computer and use it in GitHub Desktop.
Save Thorium/a5bfb0e1b118b0a7a3ff211da0df8ba3 to your computer and use it in GitHub Desktop.
Creating Azure dashboard clock component with Farmer
// Farmer F# https://compositionalit.github.io/farmer/
// Example of shaping an anonymous-object-as-JSON structure
// for an Azure dashboard using strong typing and minimal code.
// #r "nuget: Farmer"
open Farmer
open Farmer.Builders
/// TimeZone
let timezoneInfo =
// System.TimeZoneInfo.FindSystemTimeZoneById "W. Europe Standard Time" // Germany
// System.TimeZoneInfo.FindSystemTimeZoneById "Central Standard Time" // US Central time
System.TimeZoneInfo.FindSystemTimeZoneById "GMT Standard Time" // UK
/// Azure ARM-template dasboard that creates a clock of selected timezone
let clockPart (tz:System.TimeZoneInfo): Farmer.Arm.Dashboard.LensMetadata =
{ ``type`` = "Extension/HubsExtension/PartType/ClockPart"
settings =
{| content = {| settings =
{| timezoneId = tz.Id
timeFormat = "HH:mm"
version = 1 |} |} |} |> box
inputs = []
filters = None
asset = Unchecked.defaultof<Farmer.Arm.Dashboard.LensAsset>
isAdapter = System.Nullable()
defaultMenuItemId = null
}
/// Positins in the screen
let positions : Farmer.Arm.Dashboard.LensPosition list = [
{ x = 5; y = 3; colSpan = 2; rowSpan = 2 }
]
let lenspart = clockPart timezoneInfo
let dashboardGraph =
dashboard {
name "Monitoring-clock"
title "Monitoring-clock"
add_custom_lens({ position = positions.Head; metadata = lenspart })
}
//let deployment = arm {
// location deployLocation
// add_resource dashboardGraph
// // ...
//}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment