Why cost control comes before code
Every engineer who has worked with the cloud for a while has a story about a forgotten resource. A test database that stayed up all weekend, or a bigger plan picked "just to try it". The cloud bills you by the hour for anything you leave running, and it won't ask whether you meant to. So before you deploy anything in this course, you'll set up three guardrails:
- A budget that emails you as spending goes up.
- An estimate of what the finished course app should cost, so you know what normal looks like.
- A habit of opening Cost Analysis to see what is actually spending money.
Think of the budget as a smoke alarm, not a sprinkler. Azure budgets send notifications when you cross a threshold, but your resources aren't affected and your consumption isn't stopped. An alert tells you there's a fire. You still have to put it out, and later lessons always end with the command that removes what costs money.
Gotcha: On a brand-new subscription, Cost Management features can take up to 48 hours to become available. If the Budgets page looks empty or gives an error, wait a day and try again.
Step 1: Create a monthly subscription budget
In the Azure portal, open Subscriptions, select your subscription, then select Budgets in the left menu and click Add.
Fill in the form like this (it's a plan to follow, not a script to run):
Scope: your subscription # check this first; the default may differ
Name: budget-webapp-course-monthly
Reset period: Monthly # cost counter starts at zero each month
Creation date: first day of this month
Expiration: ~1 year out # an expired budget is deleted automatically
Amount: 20 # in your billing currency; pick what you'd tolerate
A reset period of Monthly, Quarterly or Annually follows calendar periods. On pay-as-you-go subscriptions you can also choose Billing month to match your invoice dates. For this course, a calendar month is fine.
Click Next to set the alert conditions. A budget needs at least one threshold and one email address, and you can add up to five thresholds and five email addresses. Each condition has a Type:
- Actual: fires when the money already spent reaches the percentage.
- Forecasted: fires when Azure projects that you'll reach the percentage by the end of the period. This is your early warning.
A sensible setup for a learning subscription:
Type % of budget Fires when...
Actual 50% you've really spent 10 of 20
Actual 80% you've really spent 16 of 20
Actual 100% you've hit the budget
Forecasted 100% the trend says you'll pass 20 this month
Alert recipients: you@example.com
The forecasted alert is the one that saves money. If you leave a database running on day 3, the actual-cost alerts may not fire until the third week. The forecast can warn you days earlier.
Best practice: Add
azure-noreply@microsoft.comto your approved senders. Otherwise budget emails can land in junk, and an alert nobody reads is no use.
Set your expectations on timing. Cost data usually shows up within 8–24 hours. Budgets are checked against it every 24 hours, and emails normally go out within an hour of that check. So a budget catches slow leaks. It won't catch a spike within minutes. That's another reason to delete resources as soon as you're done with them.
Step 2: Estimate the course app in the pricing calculator
Open the pricing calculator at https://azure.microsoft.com/pricing/calculator/. You don't need to sign in to build an estimate, but you do need to log in to save it. An estimate works like a shopping cart: you add products, then set the region, tier and hours for each.
Add the main pieces the course app will use:
Product Configuration Monthly (USD, retail)
App Service Linux, Basic B1, 1 instance, 730 h ~13.14 # 730 h x $0.018/h (West Europe)
Azure SQL Database Free offer, serverless 0.00 # within free limits
Storage account Blob, a few GB, LRS cents # tiny at course volumes
-------------------------------------------------------------------------
Estimated total ~13-14
Some notes from experience:
- 730 hours is the calculator's standard month. If you'll only run something for 40 hours, enter 40. The estimate updates straight away.
- The Azure SQL Database free offer gives each database 100,000 vCore-seconds of serverless compute, 32 GB of data and 32 GB of backup storage per month, for up to 10 databases per subscription. Leave a query tool connected and you can use that up quickly, because open connections stop the database from auto-pausing.
- Prices vary by region and change over time. Treat the numbers above as an example and trust what the calculator shows you today.
Now save the estimate. Use Save (log in when asked) and give it a name like webapp-course-baseline. Saved estimates appear under the Saved estimates tab. Export downloads an Excel file, and Share creates a link that others can view but only you can edit.
Trade-off: The calculator shows retail prices for the usage you type in. It can't know about the test VM you'll forget about. That's why you need both an estimate and a budget.
Step 3: Read Cost Analysis to find what's spending
Your estimate says what should happen. Cost Analysis shows what did happen. Open your subscription, then Cost Management → Cost analysis.
Start with the built-in smart views:
- Resource groups: cost per resource group. Later in the course each part of the app gets its own group, so this view will show which part is costing you.
- Services: cost per Azure service, such as App Service or SQL Database.
For more control, open a customizable view such as Accumulated costs, set Group by to Resource group name or Service name, and set the granularity to Daily. A healthy course month looks a bit like this:
Group by: Service name Range: this month Granularity: Daily
Service name Cost
Azure App Service 6.30 # about half a month of B1, as expected
Storage 0.04
SQL Database 0.00 # still within the free allowance
Total 6.34 # budget: 20 -> 32% used
If a row you don't recognise appears, or one service is much higher than your estimate, expand it to see the resource behind it. The ⋯ menu on that row opens the resource so you can stop or delete it.
Habit: Check Cost Analysis weekly. For the first week or two after you deploy or change something, check it daily.
Check it works, and clean up
- Your budget shows on the Budgets page with its amount and four alert conditions.
- Your saved estimate is listed under Saved estimates in the calculator.
- Cost Analysis opens and groups by resource group and service. A new subscription may show nothing yet, which is a good sign.
Nothing in this lesson creates billable resources, so there's nothing to delete. Keep the budget running for the whole course.
Key takeaways
- Budgets alert; they never stop or delete resources. Cleaning up is still your job.
- Use both actual and forecasted thresholds. Up to five thresholds and five emails per budget.
- Cost data lags 8–24 hours and budgets are checked every 24 hours, so budgets catch slow leaks, not instant spikes.
- The pricing calculator turns usage into an estimate. Save needs a login; Export gives Excel; Share gives a read-only link.
- In Cost Analysis, group by resource group and service to find where the money goes.