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
ninjarobot / du-with-partial-active-pattern.fs
Last active April 8, 2021 20:08
Using partial active patterns to return calculated data in pattern matches
/// Several types of consoles
type Console =
| Playstation_5
| Xbox_Series_X
| Switch
with
member this.Name =
match this with
| Playstation_5 -> "Playstation 5"
| Xbox_Series_X -> "XBox Series X"
@ninjarobot
ninjarobot / farmer-global-app.fsx
Last active June 18, 2021 03:37
Farmer application with multiple resource groups and traffic manager
#r "nuget: Farmer, 1.6.0"
open Farmer
open Farmer.Builders
open Farmer.Builders.ContainerGroups
open Farmer.Builders.TrafficManager
open Farmer.TrafficManager
let msi = userAssignedIdentity {
name "my-app"
@ninjarobot
ninjarobot / home-grown-farmer-resource.fsx
Created June 30, 2021 04:08
Create a minimal ARM resource to use with Farmer template generation.
#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
@ninjarobot
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
#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
ninjarobot / BuildIso.fsx
Created November 5, 2021 01:45
Builds autoinstall ISO for Ubuntu F# dev environment
#r "nuget: FsCloudInit"
#r "nuget: DiscUtils.Containers"
open System
open System.IO
open FsCloudInit
open FsCloudInit.Builders
open DiscUtils
open YamlDotNet.Serialization
@ninjarobot
ninjarobot / multiple-locations.fsx
Created November 14, 2021 15:02
Example for deploying to multiple locations with Farmer
#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
ninjarobot / install-azure-cli-macos.sh
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
deactivate
@ninjarobot
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.
#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
ninjarobot / ExecutionPlan1.fsx
Created April 16, 2022 17:29
Execution plan Computation Expressions
type Step =
| Action of string
| Branch of Step list list
type Plan =
{
Name : string
Steps : Step list
}
@ninjarobot
ninjarobot / Makefile
Last active September 6, 2022 05:49
Building nginx for macOS without homebrew
# 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 https://nginx.org/download/nginx-1.21.6.tar.gz
tar -xzvf nginx-*.tar.gz
mv nginx-*/ nginx
rm nginx-*.tar.gz