Created
September 15, 2025 08:44
-
-
Save Thorium/a5bfb0e1b118b0a7a3ff211da0df8ba3 to your computer and use it in GitHub Desktop.
Creating Azure dashboard clock component with Farmer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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