Product

Automating Azure Cost Optimization with an AI Agent

Automate Azure cost optimization with an AI agent: read-only connection, continuous scans of 7 waste sources, approval-gated fixes. Typical 30–50% cut.

·
azurecostoptimizationfinopscostopsaiagent
Cover Image for Automating Azure Cost Optimization with an AI Agent

Automating Azure Cost Optimization with an AI Agent

Open Azure Advisor's cost tab in any tenant more than a year old and you'll find the same thing: a wall of recommendations, impact estimates attached, some of them months stale. Advisor did its job. Nobody actioned the list. That backlog is the reason to automate Azure cost optimization rather than audit it harder — detection was never the bottleneck. Every fix still needs a human to validate the finding, check it against context Advisor doesn't have ("is this VM idle, or is it the quarterly batch job?"), open a ticket, and wait for a sprint slot. The backlog refills faster than tickets close.

This is part three of our Azure cost optimization series. Part one mapped the places Azure subscriptions leak money — orphaned disks, reservation coverage gaps, always-on dev/test VMs, idle networking, oversized SQL tiers, snapshot sprawl. Part two walked through auditing all of them with native tools: Cost Management, Advisor, az CLI sweeps, Azure Monitor. This article covers running those checks continuously with CloudThinker's CostOps agent — and, just as important, what the agent will not do without your explicit approval.

Why Advisor recommendations pile up

Three reasons, worth naming because any azure cost optimization tool worth adopting has to solve all three:

  1. No context. Advisor's cost recommendations come from utilization signals alone. It can't distinguish a genuinely idle VM from a warm standby, so a human triages every line before anyone acts.
  2. No remediation path. Advisor recommends; it doesn't execute. Outside of VM auto-shutdown, every fix from part two is a manual az CLI command or portal session — a ticket, a queue.
  3. Decay. The findings from your part-two audit started going stale the day you exported them. Every deploy can orphan a disk; every scale-out can open a coverage gap. A quarterly audit races daily waste and loses.

An agent that only detects would just be a second Advisor. The point of putting an AI agent on cloud cost work is continuous detection with evidence attached, plus a remediation path that executes at exactly the autonomy level you've granted — nothing more.

Connecting Azure: a read-only service principal, about five minutes

CostOps connects to Azure the way your security review would demand anyway: a service principal holding read-only roles at subscription scope. No agents installed on VMs, no stored write credentials, no exported keys sitting in a spreadsheet. The role scope is read-only at connection time — the agent can see your resources and your billing data, and can change nothing.

The setup is two commands:

az ad sp create-for-rbac \
  --name "cloudthinker-costops" \
  --role Reader \
  --scopes /subscriptions/<your-subscription-id>
az role assignment create \
  --assignee <appId-from-previous-output> \
  --role "Cost Management Reader" \
  --scope /subscriptions/<your-subscription-id>

Paste the tenant ID, client ID, and secret into the connection screen and the first scan starts. The whole flow takes about five minutes, and the connection guide in the docs lists the exact permissions requested, so your security team can review the grant before anyone clicks connect. Multi-subscription tenants repeat per subscription, or assign the roles once at management-group scope.

Continuous scanning across all seven Azure waste sources

Once connected, the agent scans the same seven waste sources you mapped in part one — including the ones a manual audit tends to skip because the evidence is tedious to assemble:

  1. Unattached managed disks and snapshotsdiskState of Unattached, cross-referenced with age and last-attach history, plus snapshots referencing disks that no longer exist.
  2. Idle or oversized VMs — sustained low CPU and network over a 30-day window, with a size-step-down proposal where the headroom supports one.
  3. Reservation and savings plan coverage gaps — coverage tracked against your stable compute baseline; when on-demand usage has held steady above coverage, the agent proposes a purchase with break-even math. When utilization on an existing reservation drops, it flags that too — an unused reservation is waste with a signature on it.
  4. Unused public IPs, idle load balancers, and App Gateways — unassociated Standard IPs, and LBs or Application Gateways with near-zero backend traffic.
  5. Over-provisioned Azure SQL — databases sitting far below their provisioned vCores or DTUs over a sustained window.
  6. Bandwidth costs — cross-region and egress charges growing out of proportion to workload, the line item almost nobody audits by hand.
  7. Non-production environments running 24/7 — dev/test VMs showing business-hours-only usage patterns but billing around the clock.

The checks are the ones you ran by hand in part two. What changes is cadence and evidence: a disk orphaned by Tuesday's deploy is a finding on Tuesday, and it arrives with the metrics window, the current monthly cost, and the projected saving as a range — the same case you'd have built manually, minus the hours. That is the practical meaning of continuous cost optimization: the audit never ends, so it never goes stale.

Graduated autonomy: Notify, Suggest, Approve, Autonomous

Every action class gets an autonomy level, set per environment:

  • Notify — the agent reports the finding. Nothing else happens. This is the default for everything.
  • Suggest — the agent attaches a specific remediation: the exact change, projected impact, rollback notes.
  • Approve — the agent stages the action and executes only after a named human approves it in the queue.
  • Autonomous — the agent executes and reports afterward. Teams typically reserve this for reversible, low-blast-radius actions in non-production — deleting an unattached disk that has been snapshotted first, applying a shutdown schedule to a dev resource group — and only after weeks of watching the agent be right at the Approve level.

Because levels are set per action class and per environment, "delete unattached disks" can be Autonomous in dev while "resize SQL" stays at Approve in production, permanently. Every finding, proposal, approval, and execution lands in an audit trail: what was found, what evidence supported it, who approved, what changed, when.

What a first analysis typically returns

The numbers below are illustrative — a composite of what first scans tend to surface on a mid-market Azure footprint around $40–45K/month. Your tenant will differ, but probably not in shape.

Finding Detail Est. monthly impact
Reservation coverage gap Compute coverage at 28%; D/E-series baseline stable for 90 days ~$5,200
Non-prod running 24/7 19 dev/test VMs and 2 AKS node pools, no shutdown schedules ~$2,700
Idle and oversized VMs 9 VMs under 8% average CPU over 30 days, one size step of headroom ~$1,400
Over-provisioned Azure SQL 4 databases provisioned roughly 4x above sustained load ~$980
Unattached disks and snapshots 44 disks (6.2 TB, mostly Premium SSD) plus 3,100 stale snapshots ~$900
Bandwidth Cross-region replication between paired regions, unreviewed ~$450
Idle networking 12 unassociated public IPs, 1 App Gateway at near-zero traffic ~$260

Roughly $11,900/month identified on day one — a bit over a quarter of the bill. Note where the weight sits: the reservation gap alone is bigger than the bottom five rows combined, and coverage plus scheduling is nearly two-thirds of the total. That matches what a careful manual audit finds on Azure, where reservation coverage tends to lag further behind baseline than on other clouds. The value isn't exotic findings — it's that this table rebuilds itself every day and every row carries an approval-gated fix.

Three prompts to start with

CostOps is conversational — you ask Alex, CloudThinker's cost engineering agent, in plain language:

  • @alex find unattached managed disks across all subscriptions
  • @alex analyze our reservation coverage and recommend purchases
  • @alex which non-prod VMs ran overnight last week?

Each answer cites the underlying data — the same Cost Management and Azure Monitor evidence you worked with in part two — so you verify rather than trust. Follow-ups work the way you'd expect: ask for the break-even on a proposed reservation, or restrict the disk sweep to one resource group, and the answer narrows accordingly.

What the agent will not do

"An AI agent connected to our Azure tenant" should trigger questions. Here are the answers:

  • It is read-only by default. The connection roles grant no write access. Remediation requires you to grant scoped write permissions and raise the autonomy level above Notify — two deliberate steps, not one.
  • Nothing changes without approval. It never deletes, resizes, purchases, or schedules unless you have explicitly set that specific action class to Autonomous for that specific environment.
  • Nothing happens off the record. Every proposed and executed action is in the audit trail with its evidence and its approver.
  • Architectural decisions stay human. It will show you that an App Gateway serves no traffic; whether that environment should exist at all is your call, and it stays yours.

If you did the part-two audit by hand, the right mental model is: that audit, running daily, with a remediation queue attached — not an autopilot you hand production keys to on day one.

Running AWS too? The same agent covers it, and there's a parallel trilogy ending with automating AWS cost optimization.

Found, approved, fixed

You know where Azure money leaks, and you know how to audit every leak natively. What the native stack can't give you is closure — findings that stay fresh and fixes that don't wait for a sprint. Teams that move from periodic manual reviews to continuous, approval-gated optimization across the full list of waste sources typically see a 30–50% reduction over the following months — a typical range, not a promise, and most of it from the two structural rows at the top of the table.

Try CloudThinker free — the free tier includes 100 premium credits, no card required. The connection guide takes your security team through the read-only setup, and your own first findings table is about an hour away.