Skip to content

Read Advisor cost recommendations from the REST API and list only the 30-day look-back variant - #426

Merged
Claudio Merola (Claudio-Merola) merged 3 commits into
microsoft:mainfrom
RobinpZA:fix/advisor-cost
Nov 18, 2026
Merged

Claudio Merola (Claudio-Merola) merged 3 commits into
microsoft:mainfrom
RobinpZA:fix/advisor-cost

Conversation

@RobinpZA

@RobinpZA Robin Pieterse (RobinpZA) commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The Advisor sheet does not match the Azure portal for cost recommendations:

  1. Retired recommendations. Advisor data comes from Resource Graph advisorresources, which keeps recommendations Advisor has already retired, for months. Reservation recommendations for VMs that were since covered by a purchase keep showing up. Resource Graph also leaves out annualSavingsAmount on unattached-disk recommendations. The portal reads the Advisor REST API, which has neither problem.
  2. Duplicate variants. Advisor returns every term × look-back (7, 30, 60 days) variant of a reservation or savings plan recommendation, so one recommendation appears up to six times. The portal shows only the 30-day look-back. The 60-day variant in particular keeps recommending reservations bought in the last two months.

Change

  • Get-ARIAPIResources also reads Microsoft.Advisor/recommendations?$filter=Category eq 'Cost' (api-version 2023-01-01) per subscription, following nextLink, filtered to Medium/High impact like the Resource Graph query. Not requested with -SkipAdvisory.
  • New Merge-ARIAdvisorCost: for each subscription whose REST read fully succeeded, replaces its Resource Graph Cost rows with the REST rows (honouring -ResourceGroup). If the call or any page fails, that subscription keeps its Resource Graph rows. With -SkipAPIs nothing changes.
  • Start-ARIAdvisoryJob keeps only the 30-day look-back variant per recommendation (the shortest one when no 30-day variant exists). Both the 1-year and 3-year terms are kept. Recommendations without a look-back are unchanged.
  • docs/features/azure-advisor.md describes both.

Verification

Live run against a production subscription, plus a full Invoke-ARI run (no errors):

Cost rows
Resource Graph (before) 39, including VM reservation recommendations last updated Aug–Oct for reservations since purchased
Advisor REST 15, same as the portal
Advisor sheet (after look-back filter) 11

Unattached-disk rows now carry their annual savings. Ad-hoc tests also covered the merge (one subscription read, one failed, -ResourceGroup, empty input) and the look-back grouping (7/30/60 × P1Y/P3Y → 2 rows; 7/60 only → the 7-day row; no look-back → kept). nextLink paging was not exercised live (the test subscription returned one page).

🤖 Generated with Claude Code

Microsoft Reviewers: Open in CodeFlow

…ce Graph

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… subscription

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dations

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Claudio-Merola
Claudio Merola (Claudio-Merola) merged commit 7ca943c into microsoft:main Nov 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants