/ CLOUD, COST, OPTIMIZATION, FINOPS, AZURE

Analyzing Azure Pricing

Customers often ask me about how to analyze their Azure costs. This is a very broad question and there are many ways to answer it. This post will focus on the different types of prices, discounts, and offers that are available. I will also provide some examples of how to use the Azure APIs to analyze your costs.

Azure Pricing

Azure has a number of different pricing models. The broadest categories are:

Then you can get discounts on the prices based on:

The question I get asked most often is how do I analyize my costs. I like to use a few specific Azure apis.

Azure APIs

These are the primary APIs I use to analyze Azure costs.

API URL Description
Retail Price Sheet API https://prices.azure.com/api/retail/prices?api-version=2023-01-01-preview&meterRegion=’primary’ Get the retail prices for Azure services.
Negotiated Price Sheet API GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default?api-version=2023-05-01 Get the negotiated discounted price sheet for EA agreements.
Exported Billing Data https://management.azure.com/{scope}/providers/Microsoft.CostManagement/exports/{exportName}?api-version=2020-06-01 Shows what was actually paid for Azure services.

I use the Retail Price Sheet as the baseline for service costs. However, this is not typically the price that you will pay. The Negotiated Price Sheet will show you the discounted price that you will pay. The Exported Billing Data will show you what you actually paid. The difference between the Retail Price Sheet and the Negotiated Price Sheet/Exported Billing Data is the discount that you received.

Exported Billing Data have two datasets:

  • ActualCost - Shows when you pay for an RI
  • AmortizedCost - Shows when you use an RI. Best used for chargeback.

The key columns are from the AmortizedCost dataset:

Column Description
EffectivePrice Cost after Discounts and RIs
Pay-as-you-goPrice Retail Price.
UnitPrice Price with Discounts. No RI applied

Azure Pricing Analyzing Example

As an Organization I want to have 90% of candidate VMs to be covered by an RI

Compute - RI Covered

This an example Recipe, which I’ve talked about in Cost Optimization Strategic Thinking, where the goal is to have 90% of candidate VMs covered by an RI.

The next step is to define the scheme and the source for the data.

Schema

Parameters may include:

  • optimal_percentage As the target to compare cost
Field Type Notes
date    
subscription_name   Filter
subscription_id nvarchar(100) Filter
resource_group nvarchar(100) Filter
ri_candidate_vm_count int Count of vms that match a specific requirement.
ri_covered_vm_count int Count of vms that used ri pricing. Compare UnitPrice to EffectivePrice from the AmortizedCost to see when an RI is used.
ri_uncovered_vm_count int Calculated ri_candidate_vm_count - ri_covered_vm_count
cost decimal Total cost for all VMs
optimal_cost decimal Calculated cost targeting optimal_percentage coverage goal.
is_forecast bool Forecasted data

The key pieces of data are around calculated the forecasted cost and the optimal cost. The forecasted cost is the cost that you will pay if you do nothing. The optimal cost is the cost that you will pay if you meet your goal. The difference between the two is the savings.

So we need to figure out where to source the data for each of these fields.

Source Data

  • cost
    • Found in the EffectivePrice column of the Exported Billing Data AmortizedCost dataset.
    • This shows what we end up paying including all discounts.
  • cost (forecasted)
    • Found in the Quantity, EffectivePrice and UnitPrice columns of the Exported Billing Data AmortizedCost dataset.
    • Use these fields during the previous time period and predict what the next time period quantity will be.
    • Use the UnitPrice from the Negotiated Price Sheet API for any servcices not found in the historic billing data.
    • The Price Sheet data includes discounted prices but not reservations.
  • optimal_cost
    • Find the ri price for each of the vm types in ri_candidate_vm_count
    • Use EffectivePrice from Exported Billing Data AmortizedCost or calculate the percetange discount from the UnitPrice from the Retail Price Sheet API

References