In Azure you pay for what you use: compute time, storage, network traffic. That is flexible, but it comes with a question: How do I keep track of what will be on the bill at the end of the month? In this lesson you learn what the costs depend on, how to estimate them up front, how to watch them in operation, and how to label resources so that costs can be traced back to their source.

The example is the made-up coffee roaster Brenner, which runs an online shop in Azure.

What affects costs

Microsoft names six factors:

Factor What it is about
Resource type The kind and settings of the resource: for a virtual machine, for example, the processor, cores, license, attached storage and network card all count.
Consumption You pay by usage. More compute time in this billing period costs more, less costs less.
Maintenance Resources that nobody needs anymore keep costing money. When a VM is removed, its associated storage or network may be left behind.
Geography The region determines the price. Costs for electricity, labor, taxes and fees differ. Network traffic also costs different amounts depending on the route.
Subscription type Some subscriptions have free allowances or credits.
Azure Marketplace Solutions from third-party vendors: you may pay the vendor itself in addition to Azure, and the vendor sets the billing.

One term stands out under geography: billing zones are something different from availability zones. They group regions only for the pricing of data transfer. Data flowing into an Azure datacenter is partly free, while data flowing out is charged by zone.

Under consumption, besides the normal pay-as-you-go there are discount models:

  • Reservations: You commit to specific resources for one or three years and pay less for it.
  • Savings plan for compute: You commit to an amount per hour for eligible compute services, for one or three years, without fixing a specific VM type.
  • Spot pricing: Azure offers unused capacity at a lower price but can reclaim it. This suits work that can tolerate an interruption, such as batch processing.

Estimating costs up front: the Pricing Calculator

With the Pricing Calculator you put together a configuration and see a cost estimate: for individual resources, for a whole solution, or based on a sample scenario. You can factor in storage type, access tier and redundancy, and compare regions. Important: the calculator is for information only, and the prices are an estimate. Nothing is deployed, and no costs are incurred.

The coffee roaster Brenner plans its shop and models an App Service, a managed database and storage there. The estimate becomes the basis for the budget and is revised later when the setup changes.

Costs in operation: Microsoft Cost Management

Once the resources exist, Microsoft Cost Management helps. The service analyzes, monitors and controls costs. Three building blocks belong to it:

  • Cost analysis: A quick visual overview of costs, by billing period, region, resource, subscription, resource group or service. This shows you where costs arise and which trends are emerging.
  • Cost alerts: A single place for budget alerts, credit alerts and department budget alerts. The last two apply to customers with an Enterprise Agreement.
  • Budgets: You set a spending limit, based on a subscription, a resource group, a service type or something else, and you set a threshold for an alert. When spending reaches it, an alert appears and, if configured that way, an email goes to the recipients. Budgets can even trigger automation that, for example, shuts down test resources.

Brenner sets a monthly budget for the test environment and has itself alerted at 80 percent. That way it notices when resources are still running after a test.

Tags: labeling resources

Tags are metadata, that is, additional information attached to a resource. A tag consists of a name and a value, for example Environment with the value Test. You can assign one or several per resource. Tags help with management, with costs (reports, cost centers), with operations, security, governance and automation.

Typical tags are AppName, CostCenter, Owner and Environment. Not every resource needs every tag. You set tags in the portal, with PowerShell or the Azure CLI, in templates or through the REST API. With Azure Policy you can enforce rules, for example that a certain tag is mandatory on new resources. Important to know: resources do not inherit tags from the subscription or resource group. A tag on the group therefore does not automatically appear on the resources inside it.

All together: a cycle

The tools work together. Before the start, you estimate with the Pricing Calculator and derive a budget from it. In operation, cost analysis shows where the money goes, and a budget alert speaks up before the limit is reached. Tags make visible who or what causes the costs. And because resources like to stay around after a test, regular cleanup is part of upkeep: whatever nobody needs anymore is removed, because it keeps causing costs. Anyone with a predictable load also checks reservations or a savings plan.

Exercise 1

The coffee roaster Brenner has three tasks for you:

  1. The boss wants to know, before the start, roughly what the shop will cost, without ordering anything.
  2. He wants to get an email when the spending of the test environment reaches 80 percent of 300 euros.
  3. At the end of the month, accounting should see the costs separated by department. All resources are in a single resource group.

Which tool or feature do you use for each? And what trap lurks in task 3?

Solution 1

  1. Pricing Calculator. It estimates without deploying anything and causes no costs.
  2. Cost Management, budget with a budget alert for the test environment: limit 300 euros, threshold 80 percent, the email goes to the recipient entered.
  3. Tags, for example CostCenter with the name of the department on every resource. Cost analysis can then be grouped by it. The trap: tags are not inherited from the resource group. Anyone who sets the tag only on the group has none on the resources. With Azure Policy the tag can be required for new resources.