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:
- Pay-as-you-go
- Azure Enterprise Agreement (EA)
- Microsoft Customer Agreement (MCA)
- Microsoft Partner Agreement (MPA)
Then you can get discounts on the prices based on:
- Azure Reservations
- Reserved Instances
- Azure Hybrid Benefit
- Azure Spot Instances
- Azure Dev/Test Pricing
- Azure Free Account
- and more…
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
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 theExported Billing Data
AmortizedCost dataset. - This shows what we end up paying including all discounts.
- Found in the
- cost (forecasted)
- Found in the
Quantity
,EffectivePrice
andUnitPrice
columns of theExported 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 theNegotiated Price Sheet API
for any servcices not found in the historic billing data. - The Price Sheet data includes discounted prices but not reservations.
- Found in the
- optimal_cost
- Find the ri price for each of the vm types in
ri_candidate_vm_count
- Use
EffectivePrice
fromExported Billing Data
AmortizedCost or calculate the percetange discount from theUnitPrice
from the Retail Price Sheet API
- Find the ri price for each of the vm types in
References
- Understand Cost Management data Azure Retail Prices overview
- Cost Management APIs overview
- Reporting APIs for Enterprise customers - Price Sheet
- Retrieve large cost datasets recurringly with exports from Cost Management
- Create and Manage Exported Data
- Understand cost details fields
- Azure Cost Management REST API
- Azure Cost Management REST API - Retail Prices
- Azure Cost Management REST API - Price Sheet
- Azure Cost Management REST API - Usage Details
- Azure Cost Management REST API - Exports