Repository navigation
Mark the main summary row of a subscription whose consumption failed - #64
Merged
stefoy merged 13 commits intoNov 25, 2026
Merged
Conversation
added 3 commits
October 28, 2026 18:25
When a subscription's usage pages could not be read, its row in the main summary still said "ok". The consumption banner names the affected subscriptions only in a non-obfuscated run; under -Obfuscate it gives a count, so the shareable summary could not say which subscription is missing its cost data. ResourceInventory.ps1 now records the name of the report folder it writes to (ReportFolder) on each subscription's consumption failure entry. The main summary marks the row of that folder "consumption incomplete". It uses the same entries the banner counts, so the sign-in skip entry, which names no subscription, marks no row. An entry without a usable ReportFolder marks no row either. The banner, the columns and the exit codes are unchanged.
In a -ParallelStreams run each stream worker wrote its consumption failure entries through Select-Object -Unique, which treats any two of these objects as equal and so kept only the first. When two subscriptions in one stream failed consumption, the banner counted one and named only the first, and the second subscription's row said "ok". The worker now writes every entry, as it already does for the metrics and collector lists and as the sequential path keeps them.
When a subscription's consumption phase is skipped because no usable Azure token could be had, its failure entry carried no report folder, so its row in the main summary still said "ok". The entry now names the report folder the same way the other consumption failure entries do, and that row says "consumption incomplete". The consumption banner still does not count a sign-in skip, as before.
pmorgenrood
pushed a commit
to pmorgenrood/resource-discovery-for-azure
that referenced
this pull request
Oct 30, 2026
…onsumption failed
pmorgenrood
pushed a commit
to pmorgenrood/resource-discovery-for-azure
that referenced
this pull request
Oct 30, 2026
…wslabs#59/awslabs#61/awslabs#64/awslabs#53/awslabs#56): run the offline harnesses on the Az PowerShell path The child-process harnesses of these PRs answered sign-in, the subscription list and Resource Graph through an 'az' stand-in. awslabs#66 drops the Azure CLI, so that stand-in is never called. Tests/Helpers/AzPsStandIns.ps1 now gives every harness Get-AzSubscription, Get-AzAccessToken -TenantId, a signed-in context and Resource Graph paging through Invoke-AzRestMethod with skip tokens, and answers each page from the harness's own graph stand-in (renamed Invoke-StandInGraph). Discovery queries go through Invoke-DiscoveryGraphQuery (awslabs#59), so the -HideRawOutput check reads those calls. awslabs#59's unparsable page is now a cut-off page (an empty property name is kept since awslabs#66), and awslabs#52's setup stop is shown with a missing Az module instead of a missing Azure CLI.
added 9 commits
November 9, 2026 10:13
…d for sign-in
When the metrics phase was skipped because the sign-in could no longer be
refreshed, the main summary named the subscription in its metrics banner
but still marked its row 'ok'. The metrics entry now records the report
folder its run writes to, as the consumption entry does, and the main
summary marks that row 'metrics incomplete' ('consumption and metrics
incomplete' when both), so an obfuscated summary also says which
subscription it is.
…ample New-RdaAllSubHtmlSummary picked the privacy banner from the obfuscation status sampled from the reports, so an -Obfuscated summary whose reports hold no records showed the Identifiable banner, while the names were hidden. The banner now follows the gate that hides the tenant id and subscription names, and says "Safe to share" only under -Obfuscated, which the wrapper passes for an -Obfuscate run: names that only look masked in a sample of records prove nothing about the rest, so that banner asks for a check before sharing. The same change is in the summary wording PR, line for line, so the two merge cleanly in either order.
The metrics and the consumption failure entries both built the report folder name from $Global:DefaultPath with their own copy of the same expression, and the main summary matches rows by that exact name. Both now call Get-ReportFolderName, so the two cannot drift apart. No output change.
The console line after the main summary is written read the sampled status, so an -Obfuscated run whose reports hold no records to sample printed 'Privacy: identifiable'. It now follows $IsObfuscated, the gate the privacy banner and the redaction already use.
Without -Obfuscated, a run whose sampled names look masked printed 'Privacy: obfuscated', while the banner asks for a check before sharing. The console line now says 'obfuscated (sample only; check before sharing)' in that case. The two comments above the banner are one.
…ts, under strict mode The consumption and metrics row marks read ReportFolder from entries that may not have it, and the privacy sample count and the run total read .Count and .Sum of what can be one item or none; under Set-StrictMode each stopped the summary. The row marks skip an entry without a folder, and the two counts are taken as on the summary-package branch, with the same text so the two merge cleanly.
Out-File -FilePath reads the path as a wildcard, so a run folder or file name with [ or ] gave no summary, or wrote one under another name.
Under -Obfuscate the collector names a Databricks, AKS-managed or scale-set resource prod_databricks_<guid>, prod_aks_<guid> or prod_vmss_<guid> (nonprod_ alike), but the masked-report check of Summary.ps1 and of the main summary matched only prod_<guid> and nonprod_<guid>. A masked report made mostly of such resources could read as identifiable. Both patterns now allow those three hints; Tests/MaskedTokenShapes.Tests.ps1 (the same file on sync/pr-64, sync/pr-67 and upstream-pr/summary-wording) checks every shape.
pmorgenrood
pushed a commit
to pmorgenrood/resource-discovery-for-azure
that referenced
this pull request
Nov 17, 2026
…/summary-consumption-row)
pmorgenrood
force-pushed
the
upstream-pr/summary-consumption-row
branch
from
November 17, 2026 23:59
3c59516 to
79d366d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
When a subscription's consumption (billing usage) collection fails during a
Run-AllSubscriptions.ps1run, its row in the main summary (MainSummary_<timestamp>.html) now says consumption incomplete instead of ok. A collection fails when a usage page still cannot be read after its retries, or when the context cannot be switched to the subscription. The row is also marked when the subscription's consumption phase is skipped because no usable Azure token could be had, for example when the sign-in can no longer be refreshed partway through a long run.Before this change, every row said ok and only the banner reported the problem:
1 subscription(s) had consumption (billing) issues.Under-Obfuscatethe banner gives a count and no names, so the obfuscated summary could not say which subscription was missing its cost data. A consumption phase skipped for sign-in was not in the summary at all: the console counted it underConsumption Failureswithout naming the subscription, printed theFAILED (auth)block, and the run exited 3.How it works:
ResourceInventory.ps1records the name of the report folder it writes to (ReportFolder) on each subscription's consumption failure entry, and on the entry it writes when the consumption phase is skipped for sign-in.New-RdaAllSubHtmlSummarymarks the row of that folder. The folder links an entry to its row, which works even when every name in the summary is an obfuscation token.-ParallelStreamsrun, each stream worker passed its consumption failure list throughSelect-Object -Unique. That cmdlet treats any two of these entries as equal, so each stream kept only its first failure. With two failures in one stream, the banner counted one and named only the first. The worker now keeps every entry, as it already does for the metrics and collector lists and as the sequential path does.Behaviour notes
(all subscriptions), not after the subscription. The console reports it as before.Consumption Failuresline and theConsumption failed subsline ofRunSummary.log. Each now matches the number of affected subscriptions, as in a sequential run.ReportFolder, and so does each metrics entry written when the metrics phase is skipped for sign-in. The console list,RunSummary.logand the diagnostics log read their fields by name, so their output is unchanged.How to test
Offline, no Azure needed:
AllSubHtmlSummary.Tests.ps1gains tests for the row: obfuscated and plain runs, a 0-resource subscription, a sign-in skip entry that names its folder (the row is marked, the banner does not count it), and entries without a usableReportFolder(missing, empty, not a string, a folder of another run, a path, a sign-in skip entry without one), none of which marks a row.ConsumptionIncompleteRow.Tests.ps1runs the realResourceInventory.ps1(the way the sequential loop calls it) and the realRun-AllSubscriptions.Stream.ps1in a child pwsh. Stand-ins replace the Azure CLI and the Az cmdlets, and HOME points at a temp folder. One subscription's usage page fails in the sequential case and two in the stream case. In a third case, one subscription's Azure token cannot be refreshed once its consumption phase starts. The test checks each report folder's consumption rows, the failure entries and the Health of each row. It is skipped on Windows, where the inner script writes toC:\InventoryReportswithout-OutputDirectory.Results on the current head (Linux, PowerShell 7):
AllSubHtmlSummary.Tests.ps137 of 37,ConsumptionIncompleteRow.Tests.ps19 of 9,MainSummaryLiteralPath.Tests.ps12 of 2 andMaskedTokenShapes.Tests.ps120 of 20 pass. The same test files onmain: 26 of 37, 3 of 9, 0 of 2 and 12 of 20 pass.In a real run: when the console prints
Consumption query failed for <subscription>, orConsumption: SKIPPED - could not establish a usable Azure context/tokenfor a subscription, open the run'sMainSummary_*.html. That subscription's row says consumption incomplete and the other rows say ok.Update: what the current head adds
ResourceInventory.ps1now recordsReportFolderon that subscription's metrics entry (also on the(subscription)entry it writes when no subscription matches). The row then says metrics incomplete, or consumption and metrics incomplete when both were hit. This works under-Obfuscatetoo.-Obfuscate, not a sample. The main summary's banner and its console line (Privacy: ...) now come from whether the run masked its output. A-Obfuscaterun says Obfuscated ... Safe to share, even when its reports hold no records to sample (before, such a run said Identifiable). A run without-Obfuscatewhose sampled names only look masked now says Obfuscated, adds that only a sample was checked, and asks you to review the reports before sharing them; the console line readsPrivacy: obfuscated (sample only; review before sharing). Before, that run was also called safe to share.prod_aks_<guid>,prod_vmss_<guid>andprod_databricks_<guid>. Before, those names counted as real ones.[or]. The main summary is now written by its literal path, so a run folder or file name holding[or]works.Set-StrictMode -Version Latest, also for health entries that carry noReportFolder(an older caller) and for a run with no reports.Merge order. Both #64 and #67 are on
mainand can merge alone. Merge #64 first, then #67. #67 carries the same privacy-banner and masked-name edits, so after #64 it has one conflict, inFunctions/AllSubHtmlSummary.Functions.ps1where the main summary is written: take #67's side (it writes under a private name, then moves the file into place, by literal path).Open limits: not run live against
main(main needs the Azure CLI), and not run on Windows.