Skip to content

Commit 7cb6402

Browse files
johnmathewsclaude
andcommitted
Update Azure CLI docs with researched pricing and cost commands
Corrected VM pricing from estimates to actual Azure retail prices (Standard_B2s_v2 = $0.096/hr). Added az rest cost query command (az costmanagement was removed in 2023), noted free credits API limitation, and added journal entry for cost investigation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ea08855 commit 7cb6402

2 files changed

Lines changed: 96 additions & 10 deletions

File tree

docs/dictionary.md

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ az group list -o table
216216

217217
# List all resources in a resource group
218218
az resource list -g DocumentStream -o table
219+
220+
# List resources in the AKS-managed resource group (VMs, disks, load balancers)
221+
az resource list -g MC_DocumentStream_DocumentStreamManagedCluster_westeurope -o table
219222
```
220223

221224
### AKS Cluster (Start / Stop)
@@ -226,15 +229,21 @@ compute billing. Storage (disks, IPs) still costs a small amount while stopped.
226229
# Check if the cluster is running
227230
az aks show -g DocumentStream -n DocumentStreamManagedCluster --query "powerState" -o tsv
228231

229-
# Stop the cluster (saves ~$3-4/day)
232+
# Stop the cluster (saves ~$5/day in compute)
230233
az aks stop -g DocumentStream -n DocumentStreamManagedCluster
231234

232-
# Start the cluster (takes a few minutes)
235+
# Start the cluster (takes 3-5 minutes)
233236
az aks start -g DocumentStream -n DocumentStreamManagedCluster
237+
238+
# Get kubectl credentials after starting
239+
az aks get-credentials -g DocumentStream -n DocumentStreamManagedCluster --overwrite-existing
234240
```
235241

236242
### PostgreSQL Flexible Server (Start / Stop)
237243
```bash
244+
# List servers
245+
az postgres flexible-server list -o table
246+
238247
# Check status
239248
az postgres flexible-server show -g DocumentStream -n <server-name> --query "state" -o tsv
240249

@@ -245,17 +254,57 @@ az postgres flexible-server stop -g DocumentStream -n <server-name>
245254
az postgres flexible-server start -g DocumentStream -n <server-name>
246255
```
247256

257+
### Check Costs (az rest)
258+
The `az costmanagement query` CLI command was removed by Microsoft in 2023. Use `az rest`
259+
to call the Cost Management API directly:
260+
261+
```bash
262+
# Cost breakdown by service, per day, this month
263+
SUB_ID=$(az account show --query id -o tsv) && az rest --method post \
264+
--url "https://management.azure.com/subscriptions/${SUB_ID}/resourceGroups/DocumentStream/providers/Microsoft.CostManagement/query?api-version=2025-03-01" \
265+
--body '{
266+
"type": "Usage",
267+
"dataset": {
268+
"aggregation": {
269+
"totalCost": { "name": "PreTaxCost", "function": "Sum" }
270+
},
271+
"granularity": "Daily",
272+
"grouping": [{ "name": "ServiceName", "type": "Dimension" }]
273+
},
274+
"timeframe": "MonthToDate"
275+
}'
276+
```
277+
278+
Other useful groupings (replace `ServiceName` above):
279+
- `ResourceType` — group by resource type (VMs, disks, LB, etc.)
280+
- `ResourceId` — group by individual resource
281+
- `MeterCategory` — group by billing meter category
282+
283+
Valid timeframes: `MonthToDate`, `WeekToDate`, `TheLastMonth`, `BillingMonthToDate`.
284+
285+
**Note:** The Cost Management API and `az consumption usage list` both return empty results
286+
for free credit / sponsorship subscriptions. For these subscription types, check costs in the
287+
Azure Portal: **Cost Management + Billing** > **Azure credits** or **Subscriptions** >
288+
your subscription > **Cost analysis**.
289+
248290
### Cost Awareness
249-
| Resource | Running cost | Stopped cost |
250-
|---|---|---|
251-
| AKS (3x Standard_B2ms) | ~$3-4/day | ~$0.30/day (disks) |
252-
| PostgreSQL (Burstable B1ms) | ~$0.50/day | ~$0.01/day (storage) |
253-
| ACR (Basic tier) | ~$0.17/day | ~$0.17/day |
254-
| Blob Storage | Pennies | Pennies |
255-
| Static public IPs | ~$0.12/day | ~$0.12/day |
291+
292+
Our setup: 2x Standard_B2s_v2 nodes, Free tier AKS control plane, Standard Load Balancer.
293+
294+
| Resource | $/hour | $/day (running) | $/day (stopped) |
295+
|---|---|---|---|
296+
| 2x Standard_B2s_v2 (2 vCPU, 8 GiB each) | $0.192 | $4.61 | $0 |
297+
| 2x OS Disk (128 GiB Standard SSD) || $0.64 | $0.64 |
298+
| Standard Load Balancer (first 5 rules) | $0.025 | $0.60 | $0.60 |
299+
| Public IP | $0.004 | $0.10 | $0.10 |
300+
| ACR (Basic tier) || $0.17 | $0.17 |
301+
| Blob Storage || Pennies | Pennies |
302+
| **Total** | | **~$6.12** | **~$1.51** |
303+
304+
If PostgreSQL Flexible Server is also running (Burstable B1ms): add ~$1.20/day.
256305

257306
**Rule of thumb:** Stop AKS and PostgreSQL when not actively working. Start them 5-10 minutes
258-
before you need them.
307+
before you need them. The cluster takes 3-5 minutes to start.
259308

260309
---
261310

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Azure Cost Investigation and Documentation
2+
3+
**Date:** 2026-03-30
4+
5+
## What happened
6+
7+
Noticed Azure free credits dropped from $200 to ~$170. Investigated what was consuming
8+
credits and how to stop the bleeding.
9+
10+
## Key findings
11+
12+
- The AKS cluster (2x Standard_B2s_v2) was running continuously since provisioning on
13+
March 29, costing ~$6/day in total (compute + disks + load balancer + IP + ACR).
14+
- The $30 spend over ~1.5 days is slightly higher than the ~$9 expected — may include a
15+
PostgreSQL Flexible Server that was provisioned and subsequently deleted (it's not
16+
running now).
17+
- The `az costmanagement query` CLI command was removed by Microsoft in 2023. Cost breakdown
18+
via CLI requires `az rest` calling the Cost Management Query API directly.
19+
- Even `az rest` returns empty results for free credit / sponsorship subscriptions — the
20+
Azure Portal is the only reliable way to check cost breakdown for our subscription type.
21+
22+
## Actions taken
23+
24+
- Stopped the AKS cluster with `az aks stop` to preserve remaining ~$170 credits.
25+
- Updated `docs/dictionary.md` with:
26+
- Corrected pricing based on actual Azure retail prices (was using rough estimates before)
27+
- Added `az rest` cost query command with free credits limitation note
28+
- Added `az aks get-credentials` reminder after cluster start
29+
- Added MC_ resource group listing command
30+
- Added `az postgres flexible-server list` command
31+
32+
## Decisions
33+
34+
- Interview is Friday April 3rd at 10:00 AM — 4 days after the 3-day build window ends.
35+
This gives time to polish and rehearse without time pressure.
36+
- Keep the cluster stopped when not actively working. Start 5 minutes before needed.
37+
- Remaining ~$170 in credits is plenty for the remaining work and demo day.

0 commit comments

Comments
 (0)