In the previous lesson we left cost as just one more criterion in the decision, and in module 1 we left an uncomfortable calculation open: with the figures from Advantages and Disadvantages of Cloud Computing, replacing the ERP server came out cheaper over five years than moving it to the cloud, but the comparison was unfair because the own server had no redundancy and nobody had put a price on an outage. In this lesson you will learn how each service model charges (IaaS, PaaS and SaaS), which hidden costs always turn up on the invoice (or outside it), what has to go into a total cost of ownership (TCO) and how to calculate it over five years with a Python script for Hortalia's whole architecture: ERP, online store, email and CRM, plus Laura's hours. You will finish with the basic FinOps practices (tags, budgets, alerts and a monthly review) and with a way of presenting the result to senior management so that it can be understood in five minutes.
Note: all the figures in this lesson are illustrative, rounded and exclude VAT. Real prices depend on the provider, the region, the plan, negotiated discounts and the date, and they change frequently. What matters is the method.
- How each model charges
1.1 IaaS: you pay for capacity, whether you use it or not
In IaaS you pay for resources that are running or reserved, not for work done. A VM doing nothing costs the same as one running at 100%.
| Item | How it is charged | Comment |
|---|---|---|
| On-demand compute | Per second or hour while the VM is allocated | Stopping without deallocating still costs money (02-01) |
| Reservations (1 or 3 years) | Discount in exchange for committing to a family/size and region | Significant discounts, larger over 3 years; you pay even if you do not use it |
| Savings plans | Commitment to an hourly spend for 1 or 3 years | Slightly smaller discount than a reservation, but more flexible (you can change size or region) |
| Spot / interruptible instances | Spare capacity at a large discount | The provider can take it away with little notice: only for tolerant workloads |
| OS and software licenses | Included in the hourly price or brought by you (BYOL, Azure Hybrid Benefit) | They can weigh as much as the VM itself |
| Disks | Per GB provisioned per month (and performance tier) | You pay for them even if the VM is deallocated |
| Object storage | Per GB stored, operations and access tier | Backups grow every month |
| Egress traffic | Per GB leaving the provider towards the internet or another region | Ingress is usually free; egress is not |
| Networking | VPN gateways, load balancers, public IPs, NAT | They charge per hour even if no traffic flows |
One important nuance that we will use shortly: reservations and savings plans discount compute, not licenses. On a VM with Windows and SQL Server with the license included, the license part is still paid at full price.
1.2 PaaS: you pay per instance, per plan or per consumption
| Pricing model | Examples | What to watch |
|---|---|---|
| Per plan instance | App Service (P0v3 plan), managed databases by size | Minimum number of instances for availability; autoscaling raises the bill during peaks |
| Per consumption or invocation | Azure Functions (Consumption/Flex Consumption), AWS Lambda, Cloud Run per request | Very cheap at rest; a function with an infinite loop or an attack can blow up the cost |
| Scale to zero | Cloud Run, Container Apps, functions | Almost no cost without traffic, in exchange for cold starts |
| Per service tier | Basic/Standard/Premium plans with different features (slots, private network, zones) | The feature you need (virtual network integration, for example) can force you up to a higher tier |
| Associated services | Storage, Key Vault, Application Insights, egress traffic | Each one is billed separately; monitoring priced per GB ingested can be a surprise |
1.3 SaaS: you pay per user (and per feature)
| Pricing model | Examples | What to watch |
|---|---|---|
| Per user per month | Microsoft 365, Google Workspace, CRM | Licenses assigned to people who no longer use them |
| Tiers | Basic, standard, professional, enterprise | Key features (SSO, auditing, API) only in the higher tiers: the "SSO tax" from 04-02 |
| Annual versus monthly commitment | Lower price with an annual commitment | You cannot reduce licenses until renewal |
| Add-ons | Advanced security, extra storage, backup, AI | They add up quickly per user |
| Per usage | Email sends, marketing contacts, API calls | It grows with the business, sometimes in steps |
A practical summary: in IaaS you have a lot of control over cost but you also have to manage it; in PaaS you pay more per unit of capacity, but only for what you use; in SaaS the cost is very predictable and grows with the number of people, not with the load.
- The hidden costs
The costs that hurt most are the ones that never appear in the provider's calculator:
| Hidden cost | Where it appears | Example at Hortalia |
|---|---|---|
| Egress traffic | IaaS and PaaS | ERP reports downloaded to the warehouse over the VPN; store photos served to customers |
| Public IPs and gateways | IaaS | The ERP's VPN Gateway charges per hour even when nobody is connected |
| Backups and replicas | All | Immutable backups in spaincentral and in francecentral; third-party backup of the email |
| Logs and monitoring | IaaS and PaaS | Application Insights and logs per GB ingested |
| Provider support | All | Basic support includes no response times; plans with response in hours are paid separately |
| Licenses | IaaS and SaaS | Windows and SQL Server on the VM; desktop licenses that a suite does not include |
| Training | All | Laura needs Azure training; users need training on the new suite |
| Migration | All | A partner to migrate mailboxes, preparing the ERP, testing |
| Parallel run | During the migration | The old server and the new VM running at the same time for weeks |
| Team time | All | Laura's and Marc's hours operating, reviewing invoices and licenses |
| Exit | All | Exporting data and rebuilding integrations if you change provider one day (05-04) |
- What a TCO includes
The TCO (Total Cost of Ownership) is the cost of having and using a solution over its whole horizon (here, five years), not the purchase price. It is structured in three blocks:
| Block | What it includes | Examples |
|---|---|---|
| Direct costs | What you pay to third parties | Hardware, licenses, subscriptions, cloud consumption, connectivity, partners |
| Indirect costs | Internal resources | IT and development hours, training, users' time during the transition |
| Cost of risk | Expected loss from incidents | Days of downtime per year × cost of a day without the system; data loss; fines |
Three rules to keep a TCO honest:
- Compare equivalent solutions. If one option has offsite backups and a VPN for the sales reps, the other must include them too (or their absence must be valued as risk).
- Exclude sunk costs. What has already been spent (the store development, the prototype) does not change with the decision.
- Separate cash from internal hours. Laura's hours have a cost, but they do not leave the bank account: if they are freed up, they are reinvested in other tasks. Management must see both figures separately.
For the cost of risk we use the expected annual loss: if a system is estimated to be down for an average of 1 day per year and a day without it costs €5,000, the expected loss is €5,000/year. It is not a prediction (perhaps nothing will happen in five years, or it will happen twice in one), but a way of putting options with different resilience in the same table.
- Hortalia: completing the ERP calculation
Sara digs out the script from 01-03. Laura goes through with her what was missing from each option.
Option A (renewed own server), what gets added:
- Offsite backup: with the backups on a USB drive in the same cabinet, a fire or a ransomware attack takes the server and the backups together. An offsite copy (cloud storage) costs around €40/month.
- Firewall with VPN so that the sales reps can see stock from their phones, something option B solves with the Azure VPN and Entra ID: €1,500 plus €300/year of support.
- Risk: a single server, a single line, no second location. From the history (half-day stoppages for hardware failures and the ransomware risk), Laura estimates 1 day of downtime per year on average.
Option B (VM in Azure), what gets added or corrected:
- Breakdown of the €650/month fee: compute 200, Windows and SQL Server licenses 330, disks 70 and immutable backups 50.
- Costs that were missing: VPN Gateway (around €130/month), recovery backups in
francecentral(€40/month, the "tens of euros" from 02-04), monitoring and egress traffic (€25/month), Laura's training (€1,500) and one month of parallel run (€650). - Correcting the discount: in 01-03 we applied 30% to the whole fee. In reality, reservations and savings plans only discount compute (€200/month); the included licenses are paid just the same. We will use illustrative discounts of 35% (1-year savings plan) and 55% (3-year reservation) on the compute.
- Risk: the VM in one zone, immutable backups, recovery in another region with an RTO of 8 hours and the second fibre line bring the expected downtime down to 0.25 days per year (around 6 hours).
- Cost of a day without the ERP: management and Sara estimate it at €5,000 (orders to shops not delivered, overtime to catch up, fruit losing freshness).
Note on Azure Hybrid Benefit. Hortalia's 2017 licenses are perpetual without Software Assurance, so today they cannot apply Hybrid Benefit (we saw this in Popular IaaS Providers). If Hortalia took out Windows Server and SQL Server subscription licenses through a partner, it could pay for the VM "without license" and bring its own. It only pays off if the cost of that subscription is lower than the €330/month of the included license; Laura will ask the partner for a quote and compare it at the first annual review. We do not include it in the calculation.
The second fibre line (€60/month) is not charged to the ERP: with email and CRM on SaaS, Hortalia needs it anyway. It is a shared cost of the architecture.
- Hortalia: the five-year TCO of the whole architecture
Laura extends the script to cover the four systems. For the store she compares the option chosen in 05-01 with Shopify; for email, keeping a renewed own email system against Microsoft 365 and Google Workspace; for the CRM, the three candidates. The own email option is compared fairly: it includes renewing the file server and the office suite for the 45 office seats, because Office 2016, like Exchange Server 2016, went out of support in October 2025. Google Workspace adds desktop Office for the 15 admin staff who work every day with the spreadsheets exported from the ERP. Hours are valued at €40/hour, the internal cost used in 01-03 (in 04-03 we used €35/h; we standardise on the more cautious figure).
# Illustrative 5-year TCO of Hortalia's architecture (euros, excluding VAT)
# All figures are ILLUSTRATIVE: they are for reasoning, not for budgeting.
YEARS = 5
INTERNAL_HOUR = 40 # internal cost per hour of Laura's or Marc's time
def tco(initial, annual, annual_hours=0, outage_days=0.0, cost_per_outage_day=0):
"""Return (direct_cost, risk_cost) over YEARS years."""
direct = sum(initial.values()) + YEARS * (sum(annual.values())
+ annual_hours * INTERNAL_HOUR)
risk = YEARS * outage_days * cost_per_outage_day
return direct, risk
# ---------------- 1. ERP ----------------
ERP_DAY_COST = 5000 # a day without the ERP: orders undelivered, overtime, fruit lost
erp_a = dict(
initial={"server": 9000, "licenses": 7000, "UPS and NAS": 2500,
"installation": 1500, "firewall with VPN for sales reps": 1500},
annual={"hardware maintenance": 600, "electricity": 700,
"offsite backup in the cloud": 480, "firewall support": 300},
annual_hours=60, outage_days=1.0)
COMPUTE_MONTH = 200 # compute share of the €650/month fee from 01-03
erp_b_annual = {"VM compute": COMPUTE_MONTH * 12, "Windows + SQL licenses": 330 * 12,
"disks": 70 * 12, "immutable backups": 50 * 12,
"VPN Gateway": 130 * 12, "DR backups francecentral": 40 * 12,
"monitoring and egress traffic": 25 * 12}
erp_b_initial = {"migration": 3000, "Laura's training": 1500,
"parallel run (1 month)": 650}
def erp_b(compute_discount):
annual = dict(erp_b_annual)
annual["VM compute"] = COMPUTE_MONTH * 12 * (1 - compute_discount)
return dict(initial=erp_b_initial, annual=annual, annual_hours=25, outage_days=0.25)
erp_options = {
"A: renewed own server": erp_a,
"B: VM, pay as you go": erp_b(0.0),
"B: VM, 1-year savings plan": erp_b(0.35),
"B: VM, 3-year reservation": erp_b(0.55),
}
print(f"{'ERP (5 years)':<41}Direct Risk Total")
for name, o in erp_options.items():
d, r = tco(**o, cost_per_outage_day=ERP_DAY_COST)
print(f"{name:<37} {d:>9,.0f} {r:>9,.0f} {d + r:>9,.0f}")
# Break-even: above what cost per day of downtime does the cloud win (1-year plan)?
d_a, _ = tco(**erp_a)
d_b, _ = tco(**erp_options["B: VM, 1-year savings plan"])
days_avoided = YEARS * (erp_a["outage_days"] - 0.25)
print(f"Break-even A vs B (1-year plan): €{(d_b - d_a) / days_avoided:,.0f} per day of downtime\n")
# ---------------- 2. Online store ----------------
store = {
"PaaS (App Service)": dict(
initial={},
annual={"baseline (2 instances, DB, Key Vault...)": 150 * 12,
"extra instances in peak season (8 instance-months)": 8 * 60,
"scaled-up DB at Christmas": 200},
annual_hours=60),
"SaaS (Shopify)": dict(
initial={"migration and redesign": 8000},
annual={"plan": 105 * 12, "apps (boxes, deliveries...)": 150 * 12,
"stock sync function": 20 * 12},
annual_hours=30),
}
# ---------------- 3. Email, office suite and files (120 users) ----------------
EMAIL_DAY_COST = 1500
email = {
"Own, renewed (Exchange + files)": dict(
initial={"email and file servers": 9000, "version upgrade": 2000,
"perpetual Office, 45 seats": 45 * 450},
annual={"Exchange subscription licenses": 4800, "antispam and backups": 1500,
"hardware and electricity": 800},
annual_hours=134, outage_days=0.75),
"Microsoft 365 (Premium + F3)": dict(
initial={"migration (partner)": 4000, "training": 2000},
annual={"licenses": 1489.50 * 12, "third-party backup": 120 * 2 * 12},
annual_hours=30, outage_days=0.1),
"Google Workspace (Plus + Frontline)": dict(
initial={"migration (partner)": 4500, "training": 2000},
annual={"licenses": 1365 * 12, "third-party backup": 120 * 2 * 12,
"desktop Office for 15 admin staff": 15 * 10 * 12},
annual_hours=30, outage_days=0.1),
}
# ---------------- 4. CRM (9 users) ----------------
crm = {
"HubSpot (entry paid plan)": dict(initial={"setup and import": 2000},
annual={"licenses": 9 * 20 * 12}, annual_hours=10),
"Pipedrive": dict(initial={"setup and import": 1500},
annual={"licenses": 9 * 30 * 12}, annual_hours=10),
"Dynamics 365 Sales": dict(initial={"implementation (partner)": 8000},
annual={"licenses": 9 * 65 * 12}, annual_hours=10),
}
for title, group, day_cost in [("Online store", store, 0), ("Email and files", email, EMAIL_DAY_COST),
("CRM", crm, 0)]:
print(f"{title + ' (5 years)':<41}Direct Risk Total")
for name, o in group.items():
d, r = tco(**o, cost_per_outage_day=day_cost)
print(f"{name:<37} {d:>9,.0f} {r:>9,.0f} {d + r:>9,.0f}")
print()
# ---------------- 5. Chosen architecture ----------------
chosen = {
"ERP on VM (1-year savings plan)": (erp_options["B: VM, 1-year savings plan"], ERP_DAY_COST),
"Store on PaaS": (store["PaaS (App Service)"], 0),
"Microsoft 365": (email["Microsoft 365 (Premium + F3)"], EMAIL_DAY_COST),
"HubSpot CRM": (crm["HubSpot (entry paid plan)"], 0),
"Shared (2nd fibre line, FinOps)": (dict(initial={}, annual={"second fibre line": 60 * 12},
annual_hours=24), 0),
}
print(f"{'Chosen architecture (5 years)':<34}{'Cash':>9}{'Internal h.':>12}{'Risk':>9}{'Total':>10}")
tot = [0, 0, 0]
for name, (o, cd) in chosen.items():
d, r = tco(**o, cost_per_outage_day=cd)
hours = YEARS * o.get("annual_hours", 0) * INTERNAL_HOUR
cash = d - hours
tot = [tot[0] + cash, tot[1] + hours, tot[2] + r]
print(f"{name:<34}{cash:>9,.0f}{hours:>12,.0f}{r:>9,.0f}{d + r:>10,.0f}")
print(f"{'TOTAL':<34}{tot[0]:>9,.0f}{tot[1]:>12,.0f}{tot[2]:>9,.0f}{sum(tot):>10,.0f}")
# What Sara needs for the budget: steady-state annual cash and one-off investments
one_off = sum(sum(o["initial"].values()) for o, _ in chosen.values())
print(f"One-off investments: €{one_off:,.0f} | steady-state annual cash: "
f"€{(tot[0] - one_off) / YEARS:,.0f}/year")
# Laura's hours: today versus the chosen architecture
today = {"ERP": 60, "email": 114, "file server": 20}
after = {"ERP on VM": 25, "Microsoft 365": 30, "CRM": 10, "FinOps and governance": 24}
freed = sum(today.values()) - sum(after.values())
print(f"\nLaura's hours: today {sum(today.values())} h/year, after {sum(after.values())} h/year, "
f"freed {freed} h/year (~€{freed * INTERNAL_HOUR:,}/year of time, not of cash)")Explanation, part by part:
- The
tcofunction is the heart of the script. It takes:initial: a dictionary of costs paid once (purchase, migration, training).annual: a dictionary of costs that repeat every year.annual_hours: internal hours per year, which it converts into euros withINTERNAL_HOUR.outage_daysandcost_per_outage_day: to calculate the expected loss from unavailability.- It returns two values: the direct cost (cash + hours) and the cost of risk, kept separate so they can be shown separately.
- Parameters with
=(for exampleannual_hours=0) have a default value: if an option has no estimated outages, there is no need to state it.
- Each option is a
dict(...)with the same keys as the parameters oftco. That is what lets you call the function withtco(**o, ...): the double asterisk "unpacks" the dictionary, so thattco(**{"initial": x, "annual": y})is equivalent totco(initial=x, annual=y). - The
erp_b(compute_discount)function builds the variants of option B. It copies the annual dictionary withdict(erp_b_annual)(so as not to modify the original) and replaces only the compute line, applying the discount. Licenses, disks and networking do not change: that is the correction with respect to 01-03. - The break-even answers the question management will ask: "and what if an outage does not cost us €5,000?". It divides the difference in direct cost between A and B by the days of downtime that B avoids over five years (5 × (1 − 0.25) = 3.75 days). The result is the cost per day of downtime above which the cloud comes out cheaper.
- The store, email and CRM blocks follow the same pattern. The loop
for title, group, day_cost in [...]walks through a list of tuples so as not to repeat the same printing code three times. - The chosen architecture block combines the option picked for each system with its cost per day of downtime, and separates three columns: cash (what is paid out), internal hours and risk.
o.get("annual_hours", 0)reads the hours if they exist and returns 0 if not. one_offadds up the initial costs of all the chosen options; subtracting them from the total cash and dividing by five gives the recurring annual spend, which is what Sara needs for the budget.- The last block compares Laura's hours today and afterwards. Python uses a comma as the thousands separator in the output (
{:,.0f}), the same format we use in the tables in the text.
Output:
ERP (5 years) Direct Risk Total A: renewed own server 43,900 25,000 68,900 B: VM, pay as you go 60,850 6,250 67,100 B: VM, 1-year savings plan 56,650 6,250 62,900 B: VM, 3-year reservation 54,250 6,250 60,500 Break-even A vs B (1-year plan): €3,400 per day of downtime Online store (5 years) Direct Risk Total PaaS (App Service) 24,400 0 24,400 SaaS (Shopify) 30,500 0 30,500 Email and files (5 years) Direct Risk Total Own, renewed (Exchange + files) 93,550 5,625 99,175 Microsoft 365 (Premium + F3) 115,770 750 116,520 Google Workspace (Plus + Frontline) 117,800 750 118,550 CRM (5 years) Direct Risk Total HubSpot (entry paid plan) 14,800 0 14,800 Pipedrive 19,700 0 19,700 Dynamics 365 Sales 45,100 0 45,100 Chosen architecture (5 years) Cash Internal h. Risk Total ERP on VM (1-year savings plan) 51,650 5,000 6,250 62,900 Store on PaaS 12,400 12,000 0 24,400 Microsoft 365 109,770 6,000 750 116,520 HubSpot CRM 12,800 2,000 0 14,800 Shared (2nd fibre line, FinOps) 3,600 4,800 0 8,400 TOTAL 190,220 29,800 7,000 227,020 One-off investments: €13,150 | steady-state annual cash: €35,414/year Laura's hours: today 194 h/year, after 89 h/year, freed 105 h/year (~€4,200/year of time, not of cash)
- Interpreting the result and analysing sensitivity
6.1 The ERP
| Option | Direct over 5 years (€) | Risk (€) | Total (€) |
|---|---|---|---|
| A: renewed own server (equivalent) | 43,900 | 25,000 | 68,900 |
| B: VM, pay as you go | 60,850 | 6,250 | 67,100 |
| B: VM, 1-year savings plan | 56,650 | 6,250 | 62,900 |
| B: VM, 3-year reservation | 54,250 | 6,250 | 60,500 |
- On direct cost, the own server is still cheaper, even after levelling up offsite backups and VPN. The cloud is not cheaper "just because"; the VPN Gateway and the included licenses weigh heavily.
- With risk included, the cloud wins, but only if a day without the ERP costs more than €3,400 (the break-even point). Management confirms that a day of peak season without delivering orders costs considerably more; in February, perhaps less. The committee accepts €5,000 as a cautious average.
- The 3-year reservation is the cheapest, but it is not chosen. In 05-04 we will analyse whether the ERP is replaced by a SaaS ERP in 2-3 years; committing to three years of a VM that may be switched off in two would be paying for nothing. A 1-year savings plan is chosen, renewable, and only after two or three months of measuring actual usage (first you right-size, then you commit).
6.2 The online store
PaaS costs around €24,400 over five years against around €30,500 for Shopify, not counting the development already done (a sunk cost). The difference is neither huge nor decisive: cost confirms, but does not decide, the conclusion from 05-01. Watch two assumptions: payment fees have been treated as equivalent in both options (on Shopify, fees may be added if you use an external gateway), and half of the PaaS cost is Marc's hours (60 h/year of operations).
6.3 Email and files
Here comes the surprise: SaaS is around €17,000 more expensive over five years than renewing an own email system (€116,520 against €99,175 including risk). The comparison, however, is not complete, and that tells against the SaaS figure: the own email option does not include mobile device management, advanced protection, Teams or retention with eDiscovery, and it requires Laura to keep patching Exchange every month (134 h/year). Laura sums it up for Sara: "we are paying about €3,400 more a year for not having a mail server exposed to the internet that has been a routine target of attacks, and for features we do not have today". The argument for SaaS here is security and functionality, not savings. Microsoft 365 and Google Workspace are around €2,000 apart over five years, a difference that does not decide on its own (it is settled in 05-04).
6.4 The CRM
HubSpot on an entry paid plan (€14,800) and Pipedrive (€19,700) are close; Dynamics 365 Sales triples the cost (€45,100) because of licenses and implementation. The current spreadsheet "costs nothing" in cash, but Jordi calculates that each sales rep loses at least half an hour a week looking for and correcting data, and that opportunities are lost without follow-up; that is a real cost that has not been added in. Watch out: if Hortalia later needs SSO or advanced automation, it would have to move up to a higher HubSpot plan, at a per-user cost several times greater; this will be revisited at the annual review.
6.5 The total and Laura's hours
| Item | 5 years (€) | Comment |
|---|---|---|
| Cash | 190,220 | €13,150 of one-off investments + €35,414/year recurring |
| Internal hours | 29,800 | Laura (ERP, email, CRM, FinOps) and Marc (store) |
| Expected risk | 7,000 | Against €30,625 with own ERP and email (25,000 + 5,625) |
| Total | 227,020 |
Laura goes from 194 to 89 hours a year spent on these systems: 105 hours freed (about 13 working days, some €4,200 of time). It is not a cash saving; Laura proposes spending them on the second fibre line, the identity review, the recovery drills and supporting Marc, tasks she never gets round to today.
- Basic FinOps: tags, budgets, alerts and a monthly review
FinOps is the practice of managing cloud cost as a shared responsibility between technical staff and finance: seeing the spend, understanding it, optimising it and deciding with it. For a company like Hortalia, four habits are enough to get started.
7.1 Tags to know who spends what
The tags defined in module 2 (proyecto, entorno, propietario, horario, gestionado_por) are extended with one for finance:
{
"proyecto": "erp",
"entorno": "produccion",
"propietario": "laura",
"centro_coste": "operaciones",
"gestionado_por": "terraform"
}centro_costelets Sara split the invoice by department (the ERP to operations, the store to online sales).- Tags are applied to resource groups and to resources; Azure Policy has built-in definitions to require a tag or to inherit it from the resource group, so that nobody creates "orphan" resources. That way, in cost analysis you can group by
centro_costeor byproyecto.
7.2 Budgets and alerts
A budget does not stop the spend: it warns you. Laura creates one per resource group. The ERP's recurring spend is around €775/month (€9,300/year of cash), so she sets it at €850:
az consumption budget create \
--budget-name presupuesto-erp-mensual \
--resource-group rg-hortalia-erp \
--amount 850 \
--category cost \
--time-grain monthly \
--start-date 2026-11-01 \
--end-date 2027-10-31--budget-name: the name of the budget.--resource-group: the scope; the budget only looks at that group's spend. It can also be created at subscription level.--amount 850: the amount in the account's billing currency.--category cost: a cost budget (there are usage budgets too).--time-grain monthly: it resets every month.--start-date: it must be the first day of a month.--end-datelimits how long it is valid; set a date and review it when it expires.
To add email alerts (what really protects you), Laura prefers to define the whole budget in a JSON file and send it to the Azure API, because that way it is versioned alongside the infrastructure as code:
{
"properties": {
"category": "Cost",
"amount": 850,
"timeGrain": "Monthly",
"timePeriod": { "startDate": "2026-11-01", "endDate": "2027-10-31" },
"notifications": {
"real-80": {
"enabled": true, "operator": "GreaterThan", "threshold": 80,
"thresholdType": "Actual",
"contactEmails": ["[email protected]", "[email protected]"]
},
"prevision-100": {
"enabled": true, "operator": "GreaterThan", "threshold": 100,
"thresholdType": "Forecasted",
"contactEmails": ["[email protected]", "[email protected]"]
}
}
}
}az rest --method put \
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/rg-hortalia-erp/providers/Microsoft.Consumption/budgets/presupuesto-erp-mensual?api-version=2023-05-01" \
--body @presupuesto-erp.jsonreal-80warns when the month's actual spend goes over 80% (€680).prevision-100warns when Azure's forecast says the month will end above 100%; it is the most useful alert because it arrives before it happens.az restmakes an authenticated request to the Azure Resource Manager API using theaz loginsession. Replace<subscription-id>with the real identifier and check the documentation for the current API version (api-version) before using it.- A word of caution: cost data arrives hours late, so a budget is no good for spotting a serious error within minutes (for example, a loop that creates resources); activity alerts and quotas are used for that.
The store has a different pattern: around €150/month at rest and considerably more in December. A fixed budget of €250/month would fire every Christmas and people would learn to ignore the alerts. Laura proposes an annual budget for rg-hortalia-shop (around €2,700) plus the monthly alert on the forecast only, and warning Sara ahead of the peak season.
7.3 Right-sizing
The measurements on the current server (average CPU of 15%, 12 GB of RAM used) justified Standard_D4s_v5. But behaviour in the cloud can be different. After two or three months in production, Laura will review the metrics and the cost recommendations from Azure Advisor:
- It shows recommendations such as underused VMs, unattached disks or unused public IPs.
- They are suggestions: an ERP VM with month-end peaks can look underused most of the time. Laura validates each recommendation before applying it and only then takes out the savings plan.
7.4 The monthly review with Sara
Half an hour a month, with a fixed agenda:
| Point | Question | Tool |
|---|---|---|
| 1. Spend versus budget | How is each resource group and each SaaS product doing? | Cost analysis grouped by tag; SaaS invoices |
| 2. Variances | What has gone up by more than 10% and why? | Comparison with the previous month |
| 3. Orphan resources | Are there forgotten disks, IPs or test environments? | Advisor, filter by entorno tag |
| 4. SaaS licenses | Are there unused licenses? (quarterly) | The Graph script from 04-04 |
| 5. Commitments | Is the savings plan being used? When does anything expire? | Reservation usage report and renewal calendar |
| 6. Actions | Who does what before the next review | Short minutes |
- Presenting the result to senior management
Senior management does not want to see the script. Laura and Sara prepare a single page:
- The decision being asked for: approve the architecture (ERP on a VM, store on PaaS, email and files on SaaS, SaaS CRM) and a budget of €13,150 of one-off investment and around €35,400 a year recurring.
- Why it is not "cheaper": in pure cash, some systems would cost less in-house; the cloud is justified by risk (from around €30,600 to €7,000 of expected loss over five years), security (out with unsupported software) and time (105 hours of Laura's a year).
- The key assumptions, in a table: cost of a day without the ERP (€5,000), illustrative prices to be confirmed with real quotes, hours valued at €40/h.
- The sensitivity: "if a day without the ERP cost less than €3,400, the own server would be cheaper; we believe it costs more".
- How it will be controlled: budgets and alerts, a monthly review with Sara and an annual review of commitments.
Management approves the approach, with one condition: replace the illustrative figures with real quotes from the Microsoft partner and from the CRM providers before signing any annual commitment.
Common Mistakes and Tips
- Comparing the cloud invoice with the price of the server. Compare the TCO of equivalent solutions, over several years, with hours and risk.
- Applying reservation discounts to everything. Reservations discount compute; licenses, disks, networking and SaaS do not go down.
- Committing before measuring. First right-size with real data; then reserve.
- Reserving for 3 years something that may change. If a system may be replaced in two years, a long commitment is a trap.
- Forgetting the parallel run and the exit. During the migration you pay twice; when you leave a provider, you pay for export and for rebuilding integrations.
- Mixing cash and internal hours into a single figure. Management must see what leaves the bank and what is reinvested time.
- Budgets that fire every month. An alert that always sounds is an alert nobody reads; adjust the amounts and use forecasts.
- Tip: keep the TCO script in the infrastructure repository and update it at the annual review with real prices; it is the financial memory of the decision.
Exercises
Exercise 1. Classify each cost as direct, indirect or risk, and say whether it is visible in the provider's calculator: a) VPN Gateway; b) Laura's training; c) the loss from a day without the ERP; d) the partner's fee for migrating mailboxes; e) Marc's hours updating Python dependencies; f) egress traffic for the store's photos.
Exercise 2. Management believes a day without the ERP costs only €2,500. Without running the script, calculate the five-year total for option A and for option B with a 1-year savings plan. Which one wins? What arguments would remain in favour of the cloud?
Exercise 3. Modify the script so that the store grows: from the second year onwards, the cost of "extra instances in peak season" increases by 20% a year. What structural change does the tco function need in order to model costs that vary by year? Propose the code.
Solutions
Solution 1.
| Cost | Type | Visible in the calculator? |
|---|---|---|
| a) VPN Gateway | Direct | Yes, if you remember to add it |
| b) Laura's training | Indirect (or direct if a course is paid for) | No |
| c) A day without the ERP | Risk | No |
| d) Migration partner | Direct (one-off) | No |
| e) Marc's hours | Indirect | No |
| f) Egress traffic | Direct | Yes, but you have to estimate the GB |
Common mistake: thinking that "what is not in the calculator does not exist". Four of the six costs do not appear in it.
Solution 2. Option A: 43,900 + 5 × 1.0 × 2,500 = €56,400. Option B (1-year plan): 56,650 + 5 × 0.25 × 2,500 = €59,775. A wins by around €3,400, consistent with €2,500 being below the break-even point (€3,400/day). In favour of the cloud there would remain arguments that have not been quantified: access for the sales reps without depending on an on-site firewall, recovery in another region tested with drills, not depending on a cabinet and a single person, and the ability to switch the VM off if the company migrates to a SaaS ERP (with A, the server is already paid for). Tip: when the difference is small compared with the uncertainty in the assumptions, decide on the qualitative criteria and say so explicitly.
Solution 3. The current function multiplies the annual cost by YEARS, which assumes a constant cost. You have to add year by year, allowing a growth factor per item:
def tco_per_year(initial, annual, growth=None, annual_hours=0):
"""Add year by year; 'growth' gives the annual % for some items."""
growth = growth or {}
total = sum(initial.values())
for year_n in range(YEARS): # year_n = 0, 1, 2, 3, 4
for item, amount in annual.items():
factor = (1 + growth.get(item, 0)) ** year_n
total += amount * factor
total += annual_hours * INTERNAL_HOUR
return total
paas = store["PaaS (App Service)"]
print(tco_per_year(paas["initial"], paas["annual"],
{"extra instances in peak season (8 instance-months)": 0.20},
paas["annual_hours"]))(1 + 0.20) ** year_n is 1 in the first year, 1.2 in the second, 1.44 in the third... The result is around €25,572 (the script prints 25571.968), some €1,170 more than with a constant cost. Common mistake: applying the growth from the first year (year_n + 1), which inflates every year.
Conclusion
In this lesson you have seen how each model charges: IaaS for capacity that is running or reserved (with reservations, savings plans and spot instances that only discount compute), PaaS per instance, plan or consumption (with scale to zero) and SaaS per user, tier and add-on. You have gone through the hidden costs that are never missing (egress traffic, gateways, backups, logs, support, licenses, training, migration, parallel run and team time) and you have learned to build an honest TCO: equivalent solutions, no sunk costs, with cash, internal hours and risk kept separate. At Hortalia you have finally completed the ERP calculation left open in module 1: on direct cost the own server is still cheaper, but once the cost of outages is included the VM in Azure wins if a day without the ERP costs more than €3,400, and a 1-year savings plan is chosen (not a 3-year one) because the future of the ERP is still to be decided. The whole architecture costs around €190,000 of cash over five years (€13,150 one-off and some €35,400 a year), cuts the expected loss from outages from around €30,600 to €7,000 and frees up 105 hours of Laura's time a year. And you have put basic FinOps in place: tags with a cost centre, budgets with forecast alerts, right-sizing before committing and a monthly review with Sara.
Cost is no longer an unknown, but management asked another question at the meeting: "are we complying with the law with our customers' data across all these providers?". In the next lesson, Security and Regulatory Compliance by Model, we will look at which security controls the customer applies in each model, what the GDPR and other rules require of a Spanish company and how to verify what providers promise.
