Skip to content

Mass-pricing of VMs on Azure based on CPU cores count and memory.

License

Notifications You must be signed in to change notification settings

itTkm/azure-vm-pricing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure VM pricing

Mass-pricing of VMs on Azure based on CPU cores count and memory. This is useful when costing a lift-and-shift migration dealing with many thousands VMS of varied sizes.

The pricing is retrieved from Virtual Machines Pricing.

🚨 This tool will only provide you with an estimation. Depending on your Azure spends you might be able to get a better deal from Microsoft. You should use the output of this tool as a coarse-grain estimation. On top of the VM price you will also need to consider storage and egress costs.

This tool is composed of two components:

  1. A Parser retrieving the pricing from Virtual Machines Pricing
  2. A Coster using the output from the Parser and a list of VM specifications to determine their price

This approach allows to decouple pricing acquisition from its usage and open the door to automation. The Parser can be scheduled to retrieve the pricing at regular interval and the Coster can then use an always up-to-date pricing.

Build Status

Build Status

Parser

Retrieve VMs hourly pricing for a specific combination of culture, currency, operating system and region.

Culture Culture display name Currency Currency display name Support
en-us English (US) USD US Dollar ($)
SAR[8] Saudi Riyal (SR)
IDR[11] Indonesian Rupiah (Rp)
cs-cz Čeština EUR[1] Euro (€)
da-dk Dansk DKK Danish Krone (kr)
de-de Deutsch EUR Euro (€)
CHF[9] Swiss Franc. (chf)
en-au English (Australia) AUD Australian Dollar ($)
en-ca English (Canada) CAD Canadian Dollar ($)
en-in English (India) INR Indian Rupee (₹)
en-gb English (UK) GBP British Pound (£)
MYR[6] Malaysian Ringgit (RM$)
ZAR[4] South African Rand (R)
NZD[7] New Zealand Dollar ($)
HKD[10] Hong Kong Dollar (HK$)
es-es Español EUR Euro (€)
ARS[5] Argentine Peso ($)
es-mx Español (MX) MXN Mexican Peso (MXN$)
fr-fr Français EUR Euro (€)
CHF[9] Swiss Franc. (chf)
fr-ca Français (Canada) CAD Canadian Dollar ($)
it-it Italiano EUR Euro (€)
CHF[9] Swiss Franc. (chf)
hu-hu Magyar EUR[1] Euro (€)
nb-no Norsk NOK Norwegian Krone (kr)
nl-nl Nederlands EUR Euro (€)
pl-pl Polski EUR[1] Euro (€)
pt-br Português (Brasil) BRL Brazilian Real (R$)
pt-pt Português EUR Euro (€)
sv-se Svenska SEK Swedish Krona (kr)
tr-tr Türkçe TRY Turkish Lira (TL)
ru-ru Pусский RUB Russian Ruble (руб)
ja-jp 日本語 JPY Japanese Yen (¥)
ko-kr 한국어 KRW Korean Won (₩)
zh-cn 中文(简体) N/A N/A N/A
zh-tw 中文(繁體) TWD Taiwanese Dollar (NT$)
HKD[10] Hong Kong Dollar (HK$)

🚨 the parser is not - yet - able to retrieve pricing for the regions east-china2, north-china2, east-china and north-china as it is available on a different website.

🚨 the parser is not able to retrieve pricing for the regions us-dod-central and us-dod-east as no virtual machines are listed as publicly available.

Parser pre-requisites

  • Node.js 12.13.0
  • Yarn 1.22.4
> cd .\parser\
> yarn

Parser usage

> cd .\parser\
> yarn crawl --culture en-us --currency USD --operating-system linux --region us-west

You can also use short names:

> yarn crawl -l en-us -c USD -o linux -r us-west

Arguments:

  • culture any of the option value in the Culture select
    • This will impact the formatting of the pricing
  • currency any of the option value in the Currency select
  • operating-system any of the option value in the OS/Software select
  • region any of the option value in the Region select

OS and Region select

In the footer:

Culture and Currency select

Parser output

Writes 2 output files in the out\ directory. One is a CSV, the other one is JSON. Both files contain the same data.

.\out\vm-pricing_<region>_<operating-system>.csv
.\out\vm-pricing_<region>_<operating-system>.json

Fields:

  • Instance
  • vCPU
  • RAM
  • Pay as You Go
  • Pay as You Go With Azure Hybrid Benefit
  • One Year Reserved
  • One Year Reserved With Azure Hybrid Benefit
  • Three Year Reserved
  • Three Year Reserved With Azure Hybrid Benefit
  • Spot
  • Spot With Azure Hybrid Benefit

Parser tests

The parser has unit tests focusing on edge cases of price formatting:

> cd .\parser\
> yarn test

The end-to-end tests attempt to compare known prices for the windows instance D2 v3 in us-west using permutations of supported culture and currency:

> cd .\parser\
> yarn e2e

Coster

Price VMs using the JSON pricing files generated by the Parser. The Coster will select the cheapest VM that has enough CPU cores and RAM.

Coster pre-requisites

  • .NET Core SDK 3.1

Coster usage

You should paste the JSON pricing files generated by the Parser in the Pricing\ folder. Setting the culture is only relevant when dealing with pricing and input files that were written using another culture with a different decimal point (e.g. comma vs period).

In Release mode:

> cd .\coster\src\AzureVmCoster
> dotnet run --configuration Release -- --input <input-path> --culture <culture>
> dotnet run --configuration Release -- -i <input-path> -l <culture>
> dotnet run --configuration Release -- -i <input-path>

The culture is optional.

In Debug mode

> cd .\coster\src\AzureVmCoster
> dotnet run --configuration Debug
Input file path: <input-path>
Culture (leave blank for system default):

You'll need to provide the <input-path> when prompted, the culture is optional.

<input-path> should point to a CSV file with the following fields:

  • Region
  • Name
  • CPU (a short)
  • RAM (in GB, a decimal)
  • Operating System

The columns can be in any order and the CSV file can contain extra-columns. The Region and Operating System fields must match existing regions and supported operating systems in Azure.

Coster output

The Coster will generate a CSV file in the Out\ directory with the following fields:

  • Region
  • Name
  • Operating System
  • Instance
  • CPU
  • RAM
  • Pay as You Go
  • Pay as You Go With Azure Hybrid Benefit
  • One Year Reserved
  • One Year Reserved With Azure Hybrid Benefit
  • Three Year Reserved
  • Three Year Reserved With Azure Hybrid Benefit
  • Spot
  • Spot With Azure Hybrid Benefit

Notes and references

01. Euro is used for countries which don't have their currency listed, are part of the European Union but not part of the Eurozone.

03. USD is used when no other currency could be matched to the country.

04. English (UK) has been selected due to the use of South African English in South Africa.

05. Spanish is considered to be the closest language to Rioplatense Spanish

06. English (UK) has been selected due to the use of Malaysian English in Malaysia.

07. English (UK) has been selected due to the use of New Zealand English in New Zealand.

08. USD is used because the Saudi riyal is pegged with the US Dollar.

09. German, French and Italian are three of the official languages of Switzerland.

10. English is one of the official languages of Hong-Kong. Traditional Chinese is one of the official scripts of Hong Kong, zh-tw is the only other culture available using Traditional Chinese.

11. English (US) has been selected because it is the default language.

About

Mass-pricing of VMs on Azure based on CPU cores count and memory.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 50.4%
  • C# 49.6%