MOFAKH.COM
← Back to profile
Azure Fundamentals

Pricing: how Azure turns usage into an invoice

Nov 20, 202616 min readWritten

Every Azure resource is metered, and the bill is just meters multiplied by prices. This part takes the bill apart: the handful of dimensions everything is priced on, the factors that move the price, which resources keep charging while doing nothing, how to estimate before building, and the tools and habits that keep costs visible and small.

This is the sixth part of the Azure series. Part 1 named measured service as one of the five properties of a cloud: you pay for what you use. That is a gift when usage is low and a trap when something is left running. This part explains exactly how usage becomes money, so that the cost of a design is something you can reason about before building it, not something you discover at the end of the month.

There are deliberately almost no prices in this part. Prices differ by region and currency, and they change. What does not change is how things are priced, and that is what is worth learning.

This is the first of four parts about money. This one covers how any bill is built. Part 7 compares the two ways of paying for compute, provisioned and serverless, and the maths that decides between them. Part 8 covers commitment discounts: reservations, savings plans and Azure Hybrid Benefit. Part 9 puts all of it together by reading a real-style cost decision from start to finish.

Everything is a meter

Each resource you create reports its usage on one or more meters. A meter measures one thing in one unit: hours a VM ran, gigabytes stored for a month, millions of function executions, gigabytes of data sent out to the internet. At the end of the billing period, each meter's usage is multiplied by its price, and the results are added up.

Diagram
your bill  =  sum over every meter of  (usage on that meter × price per unit)

A single resource often has several meters. A storage account, for example, is billed for how much data it holds, for the operations performed on it, and for data transferred out of it. So the question "how much does a storage account cost?" has no single answer; it depends on how it is used.

The units you will meet

Price lists and cost reports use a small set of units. They look odd at first, but each is just "amount of something × how long you had it":

UnitRead it asExample
vCoreone virtual processor core: the unit compute capacity is sized and sold ina database "with 8 vCores"
vCore-hourone vCore allocated (or used) for one hour8 vCores for 10 hours = 80 vCore-hours
vCore-secondthe same, per second: serverless services bill at this granularity8 vCores for 90 seconds = 720 vCore-seconds
GB-monthone gigabyte stored for a whole month50 GB kept for half a month = 25 GB-months
GB-secondone gigabyte of memory held for one second (Functions)a 0.5 GB function running 2 s = 1 GB-second
per 10,000 operationstransactions, sold in batches1 million blob reads = 100 batches

A vCore deserves a moment, because database and compute pricing is built on it. It is a share of a physical processor on the hypervisor from Part 1: Azure sells compute as a number of vCores, and the memory that comes with them is usually fixed per vCore (a few gigabytes each, depending on the hardware). So "a bigger database" mostly means "more vCores, and the memory that comes with them".

Two conversions turn up in every cost calculation, so they are worth memorizing:

Diagram
1 month  ≈ 730 hours     (365 days × 24 hours ÷ 12)
1 year   = 8,760 hours   (365 × 24)
 
monthly cost = vCores × price per vCore-hour × 730
yearly cost  = vCores × price per vCore-hour × 8,760

At USD 0.25 per vCore-hour, a database that runs 8 vCores all the time costs 8 × 0.25 × 730 = USD 1,460 a month. Small hourly prices become large monthly numbers, because there are a lot of hours in a month.

Every copy is billed

Part 3 showed that reliability comes from keeping copies in places that do not fail together. The bill follows the same rule: each copy that runs compute has its own meter.

  • A database with a high-availability (HA) replica, a standby copy kept ready to take over if the primary fails, pays for the primary's vCores and the replica's vCores. Two copies, double the compute.
  • A read replica, a copy that serves read-only queries to take load off the primary, is billed for its compute as well.
  • Storage redundancy (LRS, ZRS, GRS) costs more the more copies and places it involves.

So when a design says "8 vCores with one HA replica", the compute bill is for 16 vCores. This is the single most common mistake when estimating database costs: pricing the size you picked, and forgetting it runs twice.

The dimensions you pay for

Almost every Azure meter falls into one of a few families. Recognising which families a service uses is most of the skill of estimating its cost:

DimensionUnitTypical services
Compute timeper second or per hour that capacity is allocatedVMs, App Service plans, provisioned databases, Redis
Executionper execution, plus memory × duration (GB-seconds)Azure Functions on consumption plans
Storage capacityper GB per monthBlob storage, disks, database storage, backups
Operationsper batch of transactions (often per 10,000)storage reads and writes, queue messages, Key Vault operations
Data transferper GB leaving a regiontraffic to the internet, between regions
Data ingestionper GB receivedApplication Insights and Log Analytics
Throughputper unit of reserved capacity per hourCosmos DB request units, some messaging tiers

Two of these surprise people more than the others:

Data transfer. Sending data into Azure is generally free. Sending it out of Azure to the internet is charged per gigabyte, after a small free allowance, and so is sending it between regions. An app that serves large files to many users can find its bandwidth bill larger than its compute bill. This is also one more reason, alongside latency, to keep an application's resources in one region.

Monitoring data. Application Insights and Log Analytics charge mostly by the volume of log data ingested. A service that logs every request in detail at high traffic can produce a surprising monitoring bill. The Monitoring topic covers sampling and filtering for exactly this reason.

What moves the price

The same resource can cost very different amounts depending on choices made when creating it:

FactorEffect
Regionthe same service is priced differently in different regions
Tier or SKUBasic, Standard, Premium and similar tiers trade price against features, limits and SLAs
Sizemore processors and memory cost proportionally more
RedundancyZRS and geo-redundant options cost more than LRS, because more copies are kept
Compute modelthe same database can be provisioned (a fixed size, billed every hour) or serverless (billed per second for what it uses), at very different prices per vCore (Part 7)
Commitmentreservations and savings plans give a discount in exchange for committing to 1 or 3 years of usage (Part 8)
Interruptible capacitySpot VMs use Azure's spare capacity at a deep discount, but can be evicted at short notice
Existing licencesAzure Hybrid Benefit lets customers apply Windows Server and SQL Server licences they already own (Part 8)
Dev/Test pricingeligible subscriptions get reduced rates for non-production workloads

For learning, the first four matter. The compute model, commitments and licence benefits are the big levers for organizations running steady production workloads, and they get the next two parts to themselves.

Retail, negotiated and effective prices

"The price" of a meter is really three different numbers, and cost documents use all of them:

PriceWhat it isWhere you see it
Retail price (list price, pay-as-you-go price)the public price anyone pays with no agreement or discountthe pricing pages, the pricing calculator, the Retail Prices API
Negotiated pricea lower price agreed in a company's contract with Microsoftthe portal and cost reports of that company's subscriptions
Effective price (effective rate)what you actually paid per unit, after every discount, credit and commitmentcost analysis: total cost ÷ units used

The effective price is the one that matters for decisions. Two companies running the same database in the same region can have different effective prices, because one has a contract discount or a reservation and the other does not. When a cost document says "the retail price is 0.50 but our effective rate is 0.45", it means a discount already applies to that meter.

The Retail Prices API

Retail prices are available as data, not only on web pages. The Azure Retail Prices API is a public, unauthenticated web API that returns the list price of every meter, filterable by service, region and currency:

bash
# Retail prices for Azure SQL Database meters in West Europe, in euros
curl -G "https://prices.azure.com/api/retail/prices" \
  --data-urlencode "currencyCode='EUR'" \
  --data-urlencode "\$filter=serviceName eq 'SQL Database' and armRegionName eq 'westeurope'"

Each item in the response names the meter, its unit (for example "1 Hour") and its retailPrice. It never includes negotiated or reserved discounts for your account; for those, you look at your own cost data in Cost Management. Cost analyses quote "prices from the Retail Prices API on a given date" for exactly this reason: they are public, reproducible, and the same for everyone.

Allocated versus consumed: the most important distinction

The single most useful question to ask about any resource is: am I paying for capacity that exists, or for work that happens?

  • Allocated (provisioned) capacity is billed for as long as it exists, whether it does anything or not. A VM, an App Service plan or a provisioned database is reserved for you every hour, and every hour is charged, even at zero traffic.
  • Consumed capacity is billed only for actual use. A Functions consumption plan with no executions, or a storage account holding a few megabytes and receiving no requests, costs nothing or close to nothing.

This is the cost side of Part 1's service models. Serverless and consumption-based services can scale to zero, so their idle cost is near zero. Provisioned services cannot, so their idle cost is the full price. Neither is better in general: steady, heavy traffic is often cheaper on provisioned capacity, while bursty or low traffic is usually cheaper on consumption. Part 7 turns this rule of thumb into actual arithmetic, including the surprising case where a "pay for what you use" database ends up far more expensive than a fixed one.

What keeps charging while it does nothing

These are the usual sources of surprise bills in a learning subscription, all from the "allocated" side:

ResourceThe trap
Virtual machinesa VM shut down from inside its operating system is still allocated, and still charged for compute. Only Stop (deallocate) in Azure releases the compute.
Managed disksa VM's disks are charged even when the VM is deallocated. Only deleting them stops the charge.
Public IP addressescharged per hour while they exist, even if attached to nothing.
App Service plansthe plan is the bill, whether it runs ten apps, one app or none. Stopping an app does not stop the plan's charges. Only the Free tier, or deleting the plan, does.
Provisioned databasesan Azure SQL database on a provisioned tier is charged every hour. (Its serverless tier can pause automatically when idle, after which only storage is charged.)
Redis cachescharged per hour for as long as they exist.
Gateways and firewallsVPN gateways, application gateways and Azure Firewall carry significant hourly charges.
Logsmonitoring keeps ingesting and retaining data, and charging for it, as long as something emits it.

By contrast, the core of this path is gentle on cost: Azurite and local tools are free, a storage account holding a few test files costs almost nothing, and a Functions consumption plan includes a monthly free grant (on the classic Consumption plan, 1 million executions and 400,000 GB-seconds of execution time per subscription).

Note to self
A function app is never quite free: every function app needs a storage account of its own for internal bookkeeping, and that storage account is billed like any other. At learning volumes it rounds to nearly nothing, but it explains small storage charges appearing next to a "free" function app.

How billing is organized

The hierarchy from Part 2 meets the money here:

  • Every resource's usage is recorded against its subscription, and the subscription's charges appear on an invoice for the billing period, normally a calendar month.
  • Subscriptions belong to a billing account. Depending on how the account was set up (individual pay-as-you-go, a company agreement, or a partner), there may be further levels in between, such as billing profiles and invoice sections, which let a company route each subscription's costs to the right department.
  • Costs are visible in the portal while they accrue, usually with a delay of several hours, and the invoice is available after the period closes.

For a single learner the picture is simple: one billing account, one subscription, one invoice per month, and the free credit applied first.

Estimating before you build

The Azure Pricing Calculator is a free web tool where you add the services you plan to use, choose region, tier and size, enter expected usage, and get an estimated monthly cost. It is worth using for anything beyond a toy, because it forces the right questions: how many hours will this run? How much data will it store? How many requests? How much will it send to the internet?

The method matters more than the tool. For each resource in a design:

  1. Identify which dimensions it is billed on (from the table above).
  2. Decide whether it is allocated (charged per hour of existence) or consumed (charged per use).
  3. Estimate the usage on each dimension.
  4. Look up the unit prices for your region and tier, and multiply.

For PhotoDrop at a small scale, this exercise is revealing. The storage, function and queue costs are tied to usage and small at low traffic. The App Service plan for the API is a fixed hourly cost that dominates the bill at low traffic, and the data transfer for serving photos grows with every user. That kind of insight, which cost is fixed and which grows, is exactly what the estimate is for.

Watching costs: Cost Management

Microsoft Cost Management is the built-in set of tools for seeing and controlling spending:

  • Cost analysis breaks costs down by subscription, resource group, resource, service, meter, region or tag, and shows trends and forecasts. This is where you answer "what is actually costing money?".
  • Budgets (set up in Part 5) send alerts at thresholds of actual or forecast cost.
  • Anomaly alerts flag unusual changes in daily spending.
  • Exports deliver detailed cost data on a schedule, for reporting, and a Query API returns the same cost data to scripts, which is how a team pulls cost figures into its own reports and analyses.
  • Reservation utilization alerts warn when a commitment you have paid for is going unused (Part 8).
  • Azure Advisor, a separate service, recommends savings, such as resizing a VM that is mostly idle, deleting an unattached disk, or buying a reservation for a resource that runs all the time.

Cost data tells you what you paid. To understand why, it is paired with usage metrics from Azure Monitor: CPU percentage, memory percentage, request counts. A cost question such as "why is this database so expensive?" is almost always answered by putting the two side by side: what was billed, against what was actually used.

Tags from Part 2 become valuable here. With an environment and a project tag on every resource, cost analysis can show "PhotoDrop production" and "PhotoDrop development" as separate lines, even when they share a subscription. Without tags, a shared subscription's bill is one undivided number.

Habits that keep a learning subscription at zero

  1. Budget first. Before the first resource, with a forecast alert.
  2. One resource group per experiment, deleted afterwards. Nothing can be forgotten if everything lives in a group that gets deleted.
  3. Prefer local. If Azurite, Core Tools or Docker can do it, do it locally.
  4. Prefer consumption tiers and free tiers for anything in the cloud: the consumption Functions plan, the Free App Service tier, serverless SQL.
  5. Deallocate or delete VMs, never just shut them down from inside.
  6. Look before you leave. A weekly az resource list --output table shows everything that exists and might be costing money.
  7. Read the cost analysis in the portal once in a while, even when the number is zero, so you know what normal looks like.

The one idea to hold onto

An Azure bill is meters multiplied by prices. Every service is priced on a few dimensions (compute time, executions, storage, operations, data transfer, ingestion), measured in units like vCore-hours and GB-months, and every running copy has its own meter. The crucial question for each resource is whether it is allocated (charged for every hour it exists, even idle) or consumed (charged only for use). Compare costs at the effective price, not the list price. Estimate before building, tag so costs can be attributed, set a budget as an alarm, and delete what you are not using.

Further reading

What comes next

This part built the bill. Part 7 zooms in on its biggest line for most applications: compute. It compares the two ways of paying for the same database, provisioned (a fixed size, billed every hour) and serverless (billed per second for what it uses), works through the arithmetic that decides between them, and shows what you take on when you move from one to the other.