Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gabrielweyer/azure-vm-pricing
Mass-pricing of VMs on Azure based on CPU cores count and memory.
https://github.com/gabrielweyer/azure-vm-pricing
azure lift-and-shift virtual-machine
Last synced: 4 months ago
JSON representation
Mass-pricing of VMs on Azure based on CPU cores count and memory.
- Host: GitHub
- URL: https://github.com/gabrielweyer/azure-vm-pricing
- Owner: gabrielweyer
- License: mit
- Created: 2019-02-03T21:36:29.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-10-23T20:59:01.000Z (4 months ago)
- Last Synced: 2024-10-24T08:54:36.762Z (4 months ago)
- Topics: azure, lift-and-shift, virtual-machine
- Language: TypeScript
- Homepage:
- Size: 2.55 MB
- Stars: 26
- Watchers: 7
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# 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.
:rotating_light: This tool will only provide you with an **estimation**. Depending on your Azure spend 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][managed-disks-pricing] and [egress][bandwidth-pricing-details] costs.
This tool is composed of two components:
1. A [Parser](#parser) retrieving the prices from [Virtual Machines Pricing][virtual-machines-pricing]
2. A [Coster](#coster) using the output from the `Parser` and a list of VM specifications to determine their priceThis approach allows to decouple price acquisition from its usage and open the door to automation. The `Parser` can be scheduled to retrieve the prices at regular interval and the `Coster` can then use always up-to-date prices.
[![Build Status][github-actions-parser-shield]][github-actions-parser] ([tests documentation](./docs/parser-tests.md))
[![Build Status][github-actions-coster-shield]][github-actions-coster]
## Parser
Retrieve VMs **hourly prices** for a specific combination of **culture**, **currency**, **operating system** and **region**.
:rotating_light: the parser is not - yet - able to retrieve prices for the regions `east-china2`, `north-china2`, `east-china` and `north-china` as it is available on a [different website][azure-china].
:rotating_light: the parser is not able to retrieve prices for the regions `us-dod-central` and `us-dod-east` as no virtual machines are listed as publicly available.
### Parser pre-requisites
- [Latest Node.js LTS][latest-node-js-lts]
- [Yarn modern][yarn-modern]```powershell
> cd .\parser\
> yarn
```### Parser usage
```powershell
> cd .\parser\
> yarn crawl --culture en-us --currency usd --operating-system linux --region us-west --output-path .\out\
```You can also use short names:
```powershell
> yarn crawl -l en-us -c usd -o linux -r us-west -p .\out\
```Arguments:
- `culture`: [available cultures](#supported-cultures) (**will impact the formatting of the pricing**)
- `currency`: [available currencies](#supported-currencies)
- `operating-system`: [available OS/Software](#supported-ossoftware)
- `region`: [available regions](#supported-regions)
- `output-path`: where the output files will be written (defaults to `.\out\`)### Parser output
Writes `2` output files in the `out\` directory, or the directory specified by the `--output-path` argument. One is a `CSV`, the other one is `JSON`. Both files contain the same data.
```text
.\out\vm-pricing__.csv
.\out\vm-pricing__.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_
- _One Year Savings plan_
- _One Year Savings plan With Azure Hybrid Benefit_
- _Three Year Savings plan
- _Three Year Savings plan With Azure Hybrid Benefit_### Docker
#### Build the Docker image
You can build a `Docker` image for the `azure-vm-pricing`:
```bash
# Parser Docker image
cd parser
# For Linux machines running on x86_64 or in Windows WSL
docker build -f ./Dockerfile --platform linux/amd64 --build-arg ARCH=amd64 -t azure-vm-pricing .
# For Linux machines running on arm64, for example Apple Macbooks with Apple Silicon
docker build -f ./Dockerfile --platform linux/arm64 --build-arg ARCH=arm64 -t azure-vm-pricing .
```#### Run the Docker image
You can run the `azure-vm-pricing` image:
```bash
docker run --rm -it -v ./data:/data/ azure-vm-pricing:latest bash -c "yarn crawl --culture en-us --currency eur --operating-system linux --region europe-west -p /data/"
```## Coster
Price VMs using the `JSON` prices files generated by the `Parser`. The `Coster` will select the cheapest VM that has enough CPU cores and RAM.
### Coster pre-requisites
- [.NET SDK 8.x][dotnet-sdk]
### Coster usage
You should paste the `JSON` prices files generated by the `Parser` in the `coster\src\AzureVmCoster\Prices\` folder. Setting the `culture` is only relevant when dealing with prices and input files that were written using another culture with a different decimal point (e.g. comma vs period).
In `Release` mode:
```powershell
> cd .\coster\src\AzureVmCoster
> dotnet run --configuration Release -- --input --culture
> dotnet run --configuration Release -- --input --configuration
> dotnet run --configuration Release -- -i -l
> dotnet run --configuration Release -- -i
```The `culture` is optional.
You can exclude VMs by providing a configuration file, see [Coster configuration](#coster-configuration).
In `Debug` mode:
```powershell
> cd .\coster\src\AzureVmCoster
> dotnet run --configuration Debug
Input file path:
Configuration file path (leave blank if not used):
Culture (leave blank for system default):
```You'll need to provide the `` when prompted, the configuration file path and culture are optional.
`` 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](#supported-regions) and [supported operating systems](#supported-ossoftware) in the Virtual Machines Pricing website.
### 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_
- _One Year Savings plan_
- _One Year Savings plan With Azure Hybrid Benefit_
- _Three Year Savings plan_
- _Three Year Savings plan With Azure Hybrid Benefit_## Supported cultures
Supported cultures (newer cultures might have been added after I last updated the `README`, they're likely to be supported):
- `cs-cz` (Čeština (Česká republika))
- `da-dk` (Dansk (Danmark))
- `de-de` (Deutsch (Deutschland))
- `en-au` (English (Australia))
- `en-ca` (English (Canada))
- `en-in` (English (India))
- `en-gb` (English (United Kingdom))
- `en-us` (English (United States))
- `es-es` (Español (España))
- `es-mx` (Español (México))
- `fr-ca` (Français (Canada))
- `fr-fr` (Français (France))
- `id-id` (Indonesia (Indonesia))
- `it-it` (Italiano (Italia))
- `hu-hu` (Magyar (Magyarország))
- `nl-nl` (Nederlands (Nederland))
- `nb-no` (Norsk (Norge))
- `pl-pl` (Polski (Polska))
- `pt-br` (Português (Brasil))
- `pt-pt` (Português (Portugal))
- `sv-se` (Svenska (Sverige))
- `tr-tr` (Türkçe (Türkiye))
- `ru-ru` (Русский (Россия))
- `ko-kr` (한국어 (대한민국))
- `zh-cn` (中文(中国))
- `ja-jp` (日本語 (日本))
- `zh-tw` (繁體中文 (台灣))## Supported currencies
Supported currencies (newer currencies might have been added after I last updated the `README`, they're likely to be supported):
- `usd` (United States – Dollar ($) USD)
- `aud` (Australia – Dollar ($) AUD)
- `brl` (Brazil – Real (R$) BRL)
- `cad` (Canada – Dollar ($) CAD)
- `dkk` (Denmark – Krone (kr) DKK)
- `eur` (Euro Zone – Euro (€) EUR)
- `inr` (India – Rupee (₹) INR)
- `jpy` (Japan – Yen (¥) JPY)
- `krw` (Korea – Won (₩) KRW)
- `nzd` (New Zealand – Dollar ($) NZD)
- `nok` (Norway – Krone (kr) NOK)
- `rub` (Russia – Ruble (руб) RUB)
- `sek` (Sweden – Krona (kr) SEK)
- `chf` (Switzerland – Franc (chf) CHF)
- `twd` (Taiwan – Dollar (NT$) TWD)
- `gbp` (United Kingdom – Pound (£) GBP)## Supported OS/Software
Supported OS/Software (newer OS/Software might have been added after I last updated the `README`, they're likely to be supported):
- Linux
- `linux` (Ubuntu)
- `red-hat` (Red Hat Enterprise Linux)
- `rhel-ha` (Red Hat Enterprise Linux with HA)
- `rhel-sap-ha` (RHEL for SAP with HA)
- `rhel-sap-business` (RHEL for SAP Business Applications)
- `sles-basic` (SUSE Linux Enterprise + Patching only)
- `sles-standard` (SUSE Linux Enterprise + 24x7 Support)
- `sles-hpc-standard` (SUSE Linux Enterprise for HPC + 24x7 Support)
- `sles-sap` (SUSE Linux Enterprise for SAP Applications + 24x7 Support)
- `ubuntu-pro` (Ubuntu Pro)
- `ubuntu-advantage-essential` (Ubuntu Advantage Essential (Support))
- `ubuntu-advantage-standard` (Ubuntu Advantage Standard (Support))
- `ubuntu-advantage-advanced` (Ubuntu Advantage Advanced (Support))
- `ml-server-rhel` (Machine Learning Server on Red Hat Enterprise Linux)
- `ml-server-ubuntu` (Machine Learning Server on Ubuntu or Centos Linux)
- `sql-server-enterprise-linux` (SQL Server Enterprise Ubuntu Linux)
- `sql-server-standard-linux` (SQL Server Standard Ubuntu Linux)
- `sql-server-web-linux` (SQL Server Web Ubuntu Linux)
- `sql-server-enterprise-redhat` (SQL Server Enterprise Red Hat Enterprise Linux)
- `sql-server-standard-redhat` (SQL Server Standard Red Hat Enterprise Linux)
- `sql-server-web-redhat` (SQL Server Web Red Hat Enterprise Linux)
- `sql-server-enterprise-sles` (SQL Server Enterprise SUSE Priority)
- `sql-server-standard-sles` (SQL Server Standard SUSE Priority)
- `sql-server-web-sles` (SQL Server Web SUSE Priority)
- Windows
- `windows` (Windows OS)
- `biztalk-enterprise` (BizTalk Enterprise)
- `biztalk-standard` (BizTalk Standard)
- `ml-server-windows` (Machine Learning Server)
- `sharepoint` (SharePoint)
- `sql-server-enterprise` (SQL Server Enterprise)
- `sql-server-standard` (SQL Server Standard)
- `sql-server-web` (SQL Server Web)## Supported regions
Supported regions (newer regions might have been added after I last updated the `README`, they're likely to be supported):
- United States
- `us-central`
- `us-east`
- `us-east-2`
- `us-north-central`
- `us-south-central`
- `us-west-central`
- `us-west`
- `us-west-2`
- `us-west-3`
- United Kingdom
- `united-kingdom-south`
- `united-kingdom-west`
- United Arab Emirates
- `uae-central`
- `uae-north`
- Switzerland
- `switzerland-north`
- `switzerland-west`
- Sweden
- `sweden-central`
- `sweden-south`
- Spain
- `spain-central`
- Qatar
- `qatar-central`
- Poland
- `poland-central`
- Norway
- `norway-east`
- `norway-west`
- Mexico
- `mexico-central`
- Korea
- `korea-central`
- `korea-south`
- Japan
- `japan-east`
- `japan-west`
- Italy
- `italy-north`
- Israel
- `israel-central`
- India
- `central-india`
- `south-india`
- `west-india`
- Germany
- `germany-north`
- `germany-west-central`
- France
- `france-central`
- `france-south`
- Europe
- `europe-north`
- `europe-west`
- Canada
- `canada-central`
- `canada-east`
- Brazil
- `brazil-south`
- `brazil-southeast`
- Azure Government
- `usgov-arizona`
- `usgov-texas`
- `usgov-virginia`
- Australia
- `australia-central`
- `australia-central-2`
- `australia-east`
- `australia-southeast`
- Asia Pacific
- `asia-pacific-east`
- `asia-pacific-southeast`
- Africa
- `south-africa-north`
- `south-africa-west`## Coster configuration
The only configuration available currently is `excludedVms`, it takes an array of instance names. These instances won't be considered when costing VMs.
For example, if you want to discard all burstable VMs, you can use the below configuration file:
```json
{
"excludedVms": [
"B2ts v2",
"B2ls v2",
"B2s v2",
"B4ls v2",
"B4s v2",
"B8ls v2",
"B8s v2",
"B16ls v2",
"B16s v2",
"B32ls v2",
"B32s v2",
"B2ats v2",
"B2als v2",
"B2as v2",
"B4als v2",
"B4as v2",
"B8als v2",
"B8as v2",
"B16als v2",
"B16as v2",
"B32als v2",
"B32as v2",
"B1s",
"B1ms",
"B2s",
"B2ms",
"B4ms",
"B8ms",
"B12ms",
"B16ms",
"B20ms"
]
}
```[virtual-machines-pricing]: https://azure.microsoft.com/en-au/pricing/details/virtual-machines/windows/
[managed-disks-pricing]: https://azure.microsoft.com/en-us/pricing/details/managed-disks/
[bandwidth-pricing-details]: https://azure.microsoft.com/en-us/pricing/details/bandwidth/
[azure-china]: https://www.azure.cn/en-us/pricing/details/virtual-machines/
[dotnet-sdk]: https://dotnet.microsoft.com/download/dotnet/8.0
[github-actions-parser-shield]: https://github.com/gabrielweyer/azure-vm-pricing/actions/workflows/parser.yml/badge.svg
[github-actions-parser]: https://github.com/gabrielweyer/azure-vm-pricing/actions/workflows/parser.yml
[github-actions-coster-shield]: https://github.com/gabrielweyer/azure-vm-pricing/actions/workflows/coster.yml/badge.svg
[github-actions-coster]: https://github.com/gabrielweyer/azure-vm-pricing/actions/workflows/coster.yml
[yarn-modern]: https://yarnpkg.com/getting-started/install
[latest-node-js-lts]: https://nodejs.org/en/download/