Skip to content

Instantly share code, notes, and snippets.

@lukemerrett
Created May 6, 2018 15:00
Show Gist options
  • Save lukemerrett/4485dacf93e75dab7949427f0406c60e to your computer and use it in GitHub Desktop.
Save lukemerrett/4485dacf93e75dab7949427f0406c60e 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 gbPerSec = gb/sec
[<Measure>] type corePerSec = cores/sec
let gbCost = 0.0000038<gb/sec>
let coreCost = 0.0000112<cores/sec>
let calculateRatePerSecond (memoryInGb:float<gb>) (numCores: float<cores>) =
float(memoryInGb * gbCost) + float(numCores * coreCost)
let calculateHourlyRate (memoryInGb:float<gb>) (numCores: float<cores>) =
let costPerSec = calculateRatePerSecond memoryInGb numCores
(costPerSec * 60.0) * 60.0
calculateHourlyRate 1.5<gb> 1.0<cores>
// 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