📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

Finance tells you the Azure bill for your team's subscription tripled last month, and nobody knows why. Walk me through how you find the runaway resource with Cost Management, stop the bleeding, fix the root cause, and put budgets, alerts and guardrails in place so it doesn't happen again.

Investigating and fixing an Azure cost spike: Cost analysis by service, resource and meter, Log Analytics usage queries, common runaway causes, budgets and anomaly alerts, tagging and Azure Policy guardrails, and FinOps habits.

Senior RealWorldScenario Advanced azure azure-policy cost-management devops finops log-analytics

🎯 Key points

  • Cost analysis grouped by service, then resource, then meter, daily granularity, compare to previous month
  • Correlate the start date with deployments and config changes
  • Usual culprits: Log Analytics ingestion, scaled-up SKUs, autoscale max too high, forgotten resources, recursive triggers, egress
  • KQL on the Usage table to find which data type drove ingestion
  • Stop the bleeding first (cap, scale down, disable), then fix the cause
  • Budgets alert but don't stop spend; add cost anomaly alerts and action groups
  • Guardrails: required tags, Azure Policy allowed SKUs, daily caps, sampling
  • Ongoing FinOps: monthly review, reservations or savings plans for steady load

⏱ 30-second answer

I treat it like an incident. In Cost Management → Cost analysis I group by service, then resource, then meter, with daily granularity, to find what grew and the day it started. Then I correlate that date with the release history and the Activity Log to find the deployment or config change behind it. Common culprits are Log Analytics ingestion from debug logging, a SKU scaled up and never scaled down, autoscale with no sensible maximum, forgotten test resources, and recursive triggers.

I stop the bleeding first (daily cap, scale down, disable the loop), then fix the root cause, then add guardrails: budgets with action groups, cost anomaly alerts, required tags, Azure Policy for allowed SKUs, and OpenTelemetry sampling. The trade-off is that guardrails like hard caps can drop data or block scaling, so they must be set deliberately, not as a reflex.

🗣 Full answer (senior)

How I would answer this in an interview

"I treat a cost spike like a production incident: find it, contain it, fix it, prevent it. First I open Cost Management, Cost analysis, on the subscription, daily view for the last two months, and group by service name. That tells me what kind of thing grew, for example 'Log Analytics' or 'Azure SQL Database'. Then I group by resource and by meter to find which resource and which charge, such as 'Analytics Logs Data Ingestion'. The day the line bends usually matches a deployment or a config change, so I check the release history and the Activity Log for that day.

For example, at [company] our bill went from [A$9,000 to A$27,000] in a month. Cost analysis showed [almost all of the increase] was Log Analytics ingestion on one workspace. A KQL query on the Usage table showed AppTraces going from [3 GB to 180 GB] a day, starting the day we [deployed a release that set the default log level to Debug and turned on EF Core command logging]. I set a daily cap on the workspace as an immediate stop, reverted the log level through App Configuration without a redeploy, and then we added sampling and log-level rules per category. [The next month's bill was back to about A$9,500], and we added cost anomaly alerts so a spike would page us in a day, not a month.

The mistake I see is relying on budgets as protection. An Azure budget only sends an alert, it doesn't stop anything, and the default monthly view means you find out weeks late. I want daily anomaly alerts, tags that tell me who owns each resource, and policies that block the expensive SKUs nobody should create by accident. Cost is a non-functional requirement like latency, so it gets the same monitoring."


Where to look

Step Tool What you learn
1 Cost analysis, group by service, daily Which service grew, and when
2 Group by resource, then meter Which resource and which charge
3 Activity Log, release history What changed that day
4 Service metrics or KQL (Usage table) Why the meter grew
5 Azure Advisor cost recommendations Idle or oversized resources

Common runaway causes

Cause Meter that grows Fix
Debug logging or no sampling Log Analytics data ingestion Log levels, sampling, daily cap, Basic logs tier for verbose tables
SKU scaled up for an incident, never scaled down SQL vCore, App Service plan Scale down; alert on SKU changes
Autoscale or AKS node maximum too high, plus a hot loop Compute hours Sensible max; fix the loop
Recursive trigger (function writes to the container that triggers it) Function executions, storage transactions Separate input and output containers
Forgotten dev or load-test resources Everything in an untagged resource group Tags, expiry dates, scheduled clean-up
Cross-region or internet egress Bandwidth Keep traffic in region, use a CDN

Production example

In a typical case, a single Debug-level release took Log Analytics ingestion from about 3 GB to 180 GB a day, which at pay-as-you-go ingestion rates cost several hundred dollars a day. A daily cap stopped it within an hour, and per-category log levels plus 20% sampling kept ingestion at about 4 GB a day afterwards with no loss of useful diagnostics.

🔍 What the interviewer is checking

Checks that the candidate can investigate a cost incident methodically and put lasting guardrails in place.

Green flags

  • Uses Cost analysis by service, resource and meter with daily granularity
  • Correlates the spike with a change and finds the mechanism (for example KQL on Usage)
  • Contains first, then fixes, then prevents
  • Knows budgets don't stop spend and adds anomaly alerts, tags and policy

Red flags

  • Guesses or deletes resources without evidence
  • Thinks a budget caps spending
  • No prevention beyond "be more careful"

📚 Learn in depth

1. How Azure bills

Every resource emits usage records per meter (for example 'P1v3 hours', 'Analytics Logs Data Ingestion GB', 'LRS Write Operations'). Cost Management joins usage to prices and shows cost by subscription, resource group, resource, service, meter and tag. Data usually lands within 8–24 hours, so today's spend isn't final yet.

Resource ─▶ usage records (meter, quantity) ─▶ rating (price sheet, discounts) ─▶ Cost Management
                                                                           ├─ Cost analysis views
                                                                           ├─ Budgets ─▶ action group
                                                                           └─ Anomaly alerts

2. Reading Cost analysis well

  • Use daily granularity and accumulated vs daily charts: a step change points to one event, a steady slope to growth.
  • Compare with the previous period.
  • Group by meter last; the meter name tells you the mechanism.
  • Use amortised cost if you have reservations, or one-off purchases distort the picture.

3. Finding Log Analytics growth with KQL

Usage
| where TimeGenerated > ago(45d) and IsBillable
| summarize IngestedGB = sum(Quantity) / 1000 by DataType, bin(TimeGenerated, 1d)
| render timechart

Then drill into the table that grew:

AppTraces
| where TimeGenerated > ago(1d)
| summarize Count = count(), MB = sum(estimate_data_size(*)) / 1e6 by AppRoleName, SeverityLevel, tostring(Properties.CategoryName)
| top 20 by MB

4. Containment levers and their side effects

Lever Effect Side effect
Log Analytics daily cap Stops ingestion at the cap You lose telemetry for the rest of the day
Scale down a SKU Immediate saving Less headroom if load returns
Disable a function or trigger Stops a loop Work stops; messages back up
Delete resources Stops all cost Irreversible; check ownership first

5. Guardrails

  • Budgets at subscription and resource group level with action groups (email, Teams, webhook). They alert at thresholds such as 80% and 100% of forecast; they never stop resources.
  • Cost anomaly alerts use anomaly detection on daily cost and email when spend deviates from the pattern.
  • Tags (owner, costCentre, environment, expiresOn) enforced with Azure Policy deny or modify effects.
  • Azure Policy allowed SKUs (for example, no M-series VMs or Business Critical SQL in dev).
  • Telemetry hygiene: sampling in OpenTelemetry, log levels per category, Basic or Auxiliary logs plans for verbose tables, commitment tiers once ingestion is steady.
  • Rate optimisation: reservations or savings plans for steady compute, dev/test pricing, auto-shutdown for dev VMs, scale-to-zero where possible.

Try it yourself

  1. In a dev subscription, open Cost analysis, group by meter, and find your top three meters.
  2. Run the Usage KQL query on a workspace and identify the largest table.
  3. Create a budget with an action group that posts to a Teams channel, and a cost anomaly alert.
  4. Write an Azure Policy that denies resource groups without an owner tag and test it with az group create.

💻 Code

Guardrails as code: a budget with an action group, a daily cap on the workspace, and a tag policy, in Bicep. Plus the log configuration that prevents the classic ingestion spike.

targetScope = 'subscription'

param actionGroupId string
param startDate string = '2026-12-01'

resource budget 'Microsoft.Consumption/budgets@2023-11-01' = {
  name: 'budget-orders-prod'
  properties: {
    category: 'Cost'
    amount: 12000            // monthly, in the billing currency
    timeGrain: 'Monthly'
    timePeriod: { startDate: startDate }
    notifications: {
      forecast90: {
        enabled: true
        operator: 'GreaterThan'
        threshold: 90
        thresholdType: 'Forecasted'   // warn before the money is spent
        contactGroups: [ actionGroupId ]
      }
      actual100: {
        enabled: true
        operator: 'GreaterThan'
        threshold: 100
        contactGroups: [ actionGroupId ]
      }
    }
  }
}

// Require an owner tag on every resource group so cost can be traced to a team.
resource requireOwner 'Microsoft.Authorization/policyAssignments@2024-04-01' = {
  name: 'require-owner-tag-rg'
  properties: {
    policyDefinitionId: '/providers/Microsoft.Authorization/policyDefinitions/96670d01-0a4d-4649-9c89-2d3abc0a5025' // Require a tag on resource groups
    parameters: { tagName: { value: 'owner' } }
  }
}
// In the resource group deployment: a daily cap as a safety net, not the main control.
resource workspace 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
  name: 'log-orders-prod-aue'
  location: 'australiaeast'
  properties: {
    sku: { name: 'PerGB2018' }
    retentionInDays: 30
    workspaceCapping: { dailyQuotaGb: 20 }
  }
}
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning",
      "Microsoft.EntityFrameworkCore.Database.Command": "Warning"
    }
  }
}

⚠ Common mistakes

  • Mistake: Treating budgets as a spending limit. Why it is wrong: Azure budgets are a governance and planning tool: they notify at thresholds (and can trigger an action group or automation), but resources keep running and billing. Instead: Use budgets for oversight and forecasting with finance, anomaly alerts for speed, and automation or policy where you truly need a stop.
  • Mistake: Looking only at the monthly total. Why it is wrong: You can't see when the spike started or match it to a change. Instead: Use daily granularity and group by service, resource and meter.
  • Mistake: Deleting the expensive resource straight away. Why it is wrong: It may be production or hold data someone needs. Instead: Find the owner through tags and the Activity Log, scale down or cap first, then decide.
  • Mistake: Shipping Debug log levels or EF Core command logging to production. Why it is wrong: Log Analytics bills per GB ingested, and verbose logs can grow ingestion fifty-fold. Instead: Structured logging through ILogger exported with OpenTelemetry (the Azure Monitor distro), per-category log levels, trace sampling, and dynamic log levels through App Configuration.
  • Mistake: Leaving a daily cap as the only control. Why it is wrong: When the cap hits, you lose telemetry exactly when something is going wrong. Instead: Fix the source of the volume and keep the cap as a safety net.
  • Mistake: Untagged resources in shared subscriptions. Why it is wrong: Nobody can tell who owns what, so waste is never cleaned up. Instead: Enforce owner, environment and costCentre tags with Azure Policy.
  • Mistake: Buying reservations before the workload is stable. Why it is wrong: You commit to capacity you may not need. Instead: Right-size first, then reserve the steady baseline.

🏛 Senior insight: trade-offs

Senior engineers treat cost as an operational signal owned by the team that creates it, not as a finance problem discovered at month end. That is the core FinOps idea: engineering, finance and product share one view of spend, engineers get near-real-time visibility, and decisions are made on unit cost (per request, per customer) rather than the raw total. In practice I agree the budget and forecast with finance each quarter, review cost in a monthly team ritual, and explain spikes before the invoice does. The fastest wins are almost always telemetry volume, idle or oversized resources, and non-production environments running 24/7; rate discounts come after that.

Option When it fits Cost When not to
Budgets + action groups Every subscription and major resource group Free As the only protection
Cost anomaly alerts Catch spikes within a day Free Brand-new subscriptions with no history
Daily cap on Log Analytics Safety net for ingestion Lost telemetry when hit Primary cost control
Azure Policy allowed SKUs Dev and test subscriptions Some friction for teams Production that may need to scale up in an incident
Reservations / savings plans Stable baseline compute Commitment for 1 or 3 years Spiky or shrinking workloads

I measure it with cost per environment per month, cost per 1,000 requests or per customer (unit economics), Log Analytics GB per day, and the share of spend that is tagged. For scripted checks, az costmanagement query or the Cost Management exports to a storage account feed the same numbers into a dashboard.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions compute costs from always-on plans Why: Checks they can match compute options to load shape to control cost
    How to answer

    I choose by how much platform the team wants to run:

    • App Service: one or a few web apps, always on, deployment slots, almost no ops. Paid per plan instance.
    • Azure Functions: event-driven or spiky work (queues, timers, blobs); Flex Consumption scales per event and to zero.
    • Container Apps: containerised microservices on managed Kubernetes with KEDA scaling, revisions and scale to zero, without touching the cluster.
    • AKS: full Kubernetes when you need its API, custom networking or many services and have a platform team.

    The trade-off is control versus operations: each step towards AKS gives more control and more work. I start with the simplest option that meets the requirements and move only when I hit a concrete limit.

  2. When: Candidate mentions production versus dev environments Why: Checks they can design production hosting and justify the cost of each layer
    How to answer

    I build it in layers:

    • Compute: App Service Premium v3 (or a Container Apps workload-profile environment) in Australia East with zone redundancy, at least two instances, and a health check path.
    • Releases: a staging slot with warm-up and swap (or revisions with traffic splitting).
    • Network: traffic enters through Front Door Premium or Application Gateway with WAF, the app only accepts traffic from it; outbound uses VNet integration, and SQL, Key Vault and Storage are reached through private endpoints with public access off.
    • Identity and ops: managed identity everywhere, Application Insights and alerts on SLOs.
    • Resilience: a warm or cold standby in Australia Southeast with SQL failover groups and geo-redundant storage, all from IaC.

    The trade-off is cost and complexity (private DNS, more resources) versus a much smaller attack surface and a tested recovery path.

  3. When: Candidate mentions Application Insights and Log Analytics Why: Checks they understand how telemetry services fit into the overall Azure setup
    How to answer

    A typical .NET team uses a small, repeatable set of Azure services:

    • Compute: App Service for web apps and APIs, Azure Functions for event-driven code, Container Apps or AKS for containers.
    • Data: Azure SQL Database for relational data, Blob Storage for files, and Azure Managed Redis (the successor to Azure Cache for Redis) for caching.
    • Platform: Key Vault for secrets and certificates, App Configuration for settings and feature flags, Service Bus for messaging, Application Insights (on Azure Monitor) for telemetry.

    Everything is wired together with managed identity and Entra ID RBAC, not connection strings, and deployed with infrastructure as code. The trade-off: managed PaaS services remove patching and plumbing, but you accept each service's limits, pricing model and region availability.

🛠 Real-world problems: how you handle them

Debug logging release tripled the Azure bill through Log Analytics ingestion
Situation
A team of [eight] runs [six] .NET APIs on App Service in Australia East with workspace-based Application Insights. The monthly bill went from about [A$9,000] to [A$27,000], and finance only noticed when the invoice arrived.
Signals
Invoice spike; Cost analysis showed 'Log Analytics' as the top service with meter 'Analytics Logs Data Ingestion' rising sharply from [the 4th of the month]. No budget alert had fired because the budget was set on actual spend at 100% of a high figure.
Investigation
Cost analysis daily view grouped by service, resource, then meter pinned it to one workspace. KQL on `Usage` showed `AppTraces` ingestion going from [3] to [180] GB a day. A query on `AppTraces` grouped by category showed `Microsoft.EntityFrameworkCore.Database.Command` and one service's Debug logs as most of the volume. Release history showed a [config change merged on the 4th] that set the default log level to Debug.
Resolution
Immediate: set a 20 GB daily cap on the workspace and changed the log level through App Configuration, which the apps reloaded without a redeploy, so ingestion dropped within the hour. Real fix: per-category log levels in base configuration, OpenTelemetry sampling at [20%] for traces, moved verbose diagnostic tables to the Basic logs plan, and a pull request check that rejects Debug defaults in production settings.
Prevention
Cost anomaly alerts on the subscription, forecast-based budget alerts at 90%, a Log Analytics ingestion alert at 2x the 7-day average, required `owner` tags via Azure Policy, and a monthly cost review in the team's retro.

How to tell it (STAR)

**S:** Our team's Azure bill tripled in a month, from about [A$9,000] to [A$27,000], and we found out from the invoice. **T:** I took ownership of finding the cause and stopping it happening again. **A:** In Cost analysis, grouping by service, resource and meter showed almost all of it was Log Analytics ingestion on one workspace. A KQL query on `Usage` showed `AppTraces` jumping from [3] to [180] GB a day on the day we shipped a config change that set logging to Debug. I capped the workspace, reverted the log level through App Configuration within the hour, then added sampling, per-category log levels and anomaly alerts. **R:** The next month came in at about [A$9,500], ingestion settled at around [4] GB a day, and a later spike was caught by the anomaly alert within [24 hours].

↩ Usually asked after

More in Azure

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me