Skip to content

Instantly share code, notes, and snippets.

@slang25
Forked from lukemerrett/CalculateACICosts.fsx
Last active May 6, 2018 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slang25/97290a68383c4d02b6a2f5df860efb74 to your computer and use it in GitHub Desktop.
Save slang25/97290a68383c4d02b6a2f5df860efb74 to your computer and use it in GitHub Desktop.
Calculates the cost of an Azure Container Instances container
// Calculates the cost of an Azure Container Instances container
// Using the default Linux container with 1 vCpu and 1.5GB vRAM
[<Measure>] type gb
[<Measure>] type cores
[<Measure>] type sec
[<Measure>] type hour
[<Measure>] type pound
[<Measure>] type gbPerSec = gb/sec
[<Measure>] type corePerSec = cores/sec
let gbCost = 0.0000038<pound/(gb sec)>
let coreCost = 0.0000112<pound/(cores sec)>
let secondsPerHour = 60. * 60.<sec/hour>
let calculateRatePerSecond (memoryInGb:float<gb>) (numCores: float<cores>) =
(memoryInGb * gbCost) + (numCores * coreCost)
let calculateHourlyRate (memoryInGb:float<gb>) (numCores: float<cores>) =
let costPerSec = calculateRatePerSecond memoryInGb numCores
costPerSec * secondsPerHour
calculateHourlyRate 1.5<gb> 1.0<cores> |> printfn "%f"
// 0.6p / hour
// £1.46 / day
// £43.80 / month
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment