1.1.2 • Published 2 years ago

azure-retail-prices v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

azure-retail-prices

npm version npm downloads MIT License Build Status Coverage Status

This is wrapper of Azure Retail Prices API.
You can easily get the retail price of Azure without authenticating.

Installation

# via npm
npm install --save azure-retail-prices

# via yarn
yarn add azure-retail-prices

Examples

After having cloned this repository, run the following commands:

cd example/
npm install
npm run import-sample
# # or
# npm run require-sample

Usage

import arp from "azure-retail-prices";
// // or
// const arp = require("azure-retail-prices").default;

async function getRetailPrices() {
  // without currencyCode option (It will return USD)
  let retailPrices = await arp({
    serviceName: "Virtual Machines",
    location: "EU West",
    priceType: "Reservation",
  });
  console.dir(retailPrices);

  // with currencyCode option
  retailPrices = await arp(
    {
      serviceName: "Virtual Machines",
      location: "EU West",
      priceType: "Reservation",
    },
    "JPY"
  );
  console.dir(retailPrices);
}

Sample calls

Here are some examples:

// Compute resources
//  - Response count: 150K+
//  - Response time: 25 minutes
const retailPrices = await arp({
  serviceFamily: "Compute",
});

// Virtual machines
//  - Response count: 130K+
//  - Response time: 20 minutes
const retailPrices = await arp({
  serviceName: "Virtual Machines",
});

// Virtual machines located "EU West"
//  - Response count: 4K+
//  - Response time: 40 seconds
const retailPrices = await arp({
  serviceName: "Virtual Machines",
  location: "EU West",
});

// Virtual machines located "EU West" with currency in EUR
//  - Response count: 4K+
//  - Response time: 40 seconds
const retailPrices = await arp(
  {
    serviceName: "Virtual Machines",
    location: "EU West",
  },
  "EUR"
);

// Reserved virtual machines located "EU West"
//  - Response count: 700+
//  - Response time: 8 seconds
const retailPrices = await arp({
  serviceName: "Virtual Machines",
  location: "EU West",
  priceType: "Reservation",
});

// Identify by unique ID
//  - Response count: 2
//  - Response time: 1 second
const retailPrices = await arp({
  meterId: "000a794b-bdb0-58be-a0cd-0c3a0f222923",
});

Response examples

Here's a sample response, without reservation prices.

[
  {
    "currencyCode": "USD",
    "tierMinimumUnits": 0.0,
    "retailPrice": 0.176346,
    "unitPrice": 0.176346,
    "armRegionName": "westeurope",
    "location": "EU West",
    "effectiveStartDate": "2020-08-01T00:00:00Z",
    "meterId": "000a794b-bdb0-58be-a0cd-0c3a0f222923",
    "meterName": "F16s Spot",
    "productId": "DZH318Z0BQPS",
    "skuId": "DZH318Z0BQPS/00TG",
    "productName": "Virtual Machines FS Series Windows",
    "skuName": "F16s Spot",
    "serviceName": "Virtual Machines",
    "serviceId": "DZH313Z7MMC8",
    "serviceFamily": "Compute",
    "unitOfMeasure": "1 Hour",
    "type": "DevTestConsumption",
    "isPrimaryMeterRegion": true,
    "armSkuName": "Standard_F16s"
  }
]

Here's a sample response with reservation prices and term in the response.

[
  {
    "currencyCode": "USD",
    "tierMinimumUnits": 0.0,
    "reservationTerm": "1 Year",
    "retailPrice": 25007.0,
    "unitPrice": 25007.0,
    "armRegionName": "southcentralus",
    "location": "US South Central",
    "effectiveStartDate": "2020-08-01T00:00:00Z",
    "meterId": "0016083a-928f-56fd-8eeb-39287dcf676d",
    "meterName": "E64 v4",
    "productId": "DZH318Z0D1L7",
    "skuId": "DZH318Z0D1L7/018J",
    "productName": "Virtual Machines Ev4 Series",
    "skuName": "E64 v4",
    "serviceName": "Virtual Machines",
    "serviceId": "DZH313Z7MMC8",
    "serviceFamily": "Compute",
    "unitOfMeasure": "1 Hour",
    "type": "Reservation",
    "isPrimaryMeterRegion": true,
    "armSkuName": "Standard_E64_v4"
  }
]

Filters

You can append the filters to function call, as shown in the Sample calls.

Filters are supported for the following fields:

FieldsExample ValuesDefinition
armRegionNamewesteuropeARM region where the service is available. This version only supports prices on Commercial Cloud.
locationEU WestAzure data center where the resource is deployed
meterId000a794b-bdb0-58be-a0cd-0c3a0f222923Unique identifier of the resource
meterNameF16s SpotName of the meter
productIdDZH318Z0BQPSUniqueID of the product
skuIdDZH318Z0BQPS/00TGUniqueID for the SKU
productNameVirtual Machines FS Series WindowsProduct name
skuNameF16s SpotSKU name
serviceNameVirtual MachinesName of the service
serviceIdDZH313Z7MMC8UniqueID of the service
serviceFamilyComputeService family of the SKU
priceTypeDevTestConsumptionMeter consumption type. Other types are Reservation, Consumption.
armSkuNameStandard_F16sSKU name registered in Azure

Supported currencies

You append the currency code to the API endpoint, as shown in the API sample call.

Currency codeDetail
USDUS dollar
AUDAustralian dollar
BRLBrazilian real
CADCanadian dollar
CHFSwiss franc
CNYChinese yuan
DKKDanish krone
EUREuro
GBPBritish pound
INRIndian rupee
JPYJapanese yen
KRWKorean won
NOKNorwegian krone
NZDNew Zealand dollar
RUBRussian ruble
SEKSwedish krona
TWDTaiwan dollar

License

This library is licensed under the MIT License.