Skip to content

Instantly share code, notes, and snippets.

View ninjarobot's full-sized avatar

Dave Curylo ninjarobot

  • Microsoft @Azure
  • Atlanta, GA
View GitHub Profile
ninjarobot / BasicIoC.fsx
Created May 2, 2022 17:49
Basic IoC using DI in F#
View BasicIoC.fsx
#r "nuget: Microsoft.Extensions.DependencyInjection"
#r "nuget: Microsoft.Extensions.Hosting"
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Hosting
type Foo = { Foo : string }
type Bar = { Bar : int }
type FooBar = Foo -> Bar
ninjarobot /
Last active August 17, 2023 15:17
Correlated tracing in F# with Application Insights

Tracing with Application Insights

Application logging is ubiquitous and invaluable for troubleshooting. Structured logging enables you to log formatted messages and the data fields separately so that you can see the messages but also filter on the data fields. Tracing takes this a step further, where you can correlate many log entries together as you follow a trace of execution through an application. Traces also include additional information about the execution process, such as the sequence of calls to dependencies and how long any given call may take.

Application Insights lets you see all of this data correlated together in an application. You can search for an error log and then see in the execution flow that the log entry was added right after a failed call to another service. Or you can see that a certain web request is slower than others because it spends a lot of time on many redundant data access calls.

What about OpenTelemetry?

ninjarobot / Makefile
Last active September 6, 2022 05:49
Building nginx for macOS without homebrew
View Makefile
# default target so running 'make' by itself wll download and build nginx
build: nginx
cd nginx && ./configure --with-pcre=../pcre2 && make
nginx: pcre2
curl -O
tar -xzvf nginx-*.tar.gz
mv nginx-*/ nginx
rm nginx-*.tar.gz
ninjarobot / ExecutionPlan1.fsx
Created April 16, 2022 17:29
Execution plan Computation Expressions
View ExecutionPlan1.fsx
type Step =
| Action of string
| Branch of Step list list
type Plan =
Name : string
Steps : Step list
ninjarobot / ContainerApps-full-workflow.fsx
Last active December 19, 2021 19:23
Full workflow for Azure container apps with Farmer - build and push container, deploy to app.
View ContainerApps-full-workflow.fsx
#r "../../src/Farmer/bin/Debug/net5.0/Farmer.dll"
#r "nuget: FSharp.Text.Docker"
open System
open Farmer
open Farmer.ContainerApp
open Farmer.Builders
open FSharp.Text.Docker.Builders
// Create Container Registry
ninjarobot /
Created November 20, 2021 13:34
Install the Azure CLI on macOS
set -eux
python3 -m venv $HOME/venvs/azure-cli
source venvs/azure-cli/bin/activate
pip install --upgrade pip
pip install azure-cli
ninjarobot / multiple-locations.fsx
Created November 14, 2021 15:02
Example for deploying to multiple locations with Farmer
View multiple-locations.fsx
#r "nuget:Farmer"
open Farmer
open Farmer.Builders
// Sometimes resources aren't available in certain regions and another location needs to be chosen.
// The best way to do this is to create a nested resource group deployment to the _same_ resource
// group, and choose a different location for that nested deployment
arm {
ninjarobot / BuildIso.fsx
Created November 5, 2021 01:45
Builds autoinstall ISO for Ubuntu F# dev environment
View BuildIso.fsx
#r "nuget: FsCloudInit"
#r "nuget: DiscUtils.Containers"
open System
open System.IO
open FsCloudInit
open FsCloudInit.Builders
open DiscUtils
open YamlDotNet.Serialization
ninjarobot / acr-workflow.fsx
Last active July 27, 2021 03:27
Deploys an Azure Container Registry, builds Docker image, pushes it there, hosts in ACI
View acr-workflow.fsx
#r "nuget: Farmer"
#r "nuget: FSharp.Text.Docker"
open System
open Farmer
open Farmer.Builders
open FSharp.Text.Docker.Dockerfile
// Create Container Registry
let myAcr =
ninjarobot / home-grown-farmer-resource.fsx
Created June 30, 2021 04:08
Create a minimal ARM resource to use with Farmer template generation.
View home-grown-farmer-resource.fsx
#r "nuget: Farmer"
open Farmer
// Give it a resource type. This is helpful the resource and handling dependencies.
let rightClickDeployments = ResourceType ("Microsoft.Hi/rightClickDeployments", "2021-06-29")
// Define the resource itself.
let minimalResource =
{ new IArmResource with