CostManagement: tolerate NotFound 'returns null or empty list for id' for new/parked subscriptions - #59
Conversation
New/parked subscriptions not yet onboarded to Cost Management return a
string-coded 'NotFound' ('GtmDimensionDataProvider.GetAzureSubscriptionsById
returns null or empty list for id: ...'). This was not matched by the
CostManagement rule set and fell through to the generic Stop handler,
aborting the whole run.
Treat it like the existing numeric-404 'created recently' case: skip the
subscription and return an empty collection.
Fixes JulianHayward#58
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Hey @JanElholm, The problem seems to be random and not affecting each and every time the same subscription. On the 30th of June it was the last successful run and with the 1st of July the problem started. I understood and saw the issue in the Azure Portal as well: However, I like your Pull Request but I suggest to adjust it, as the AzAPICall is having an exception which should be documented. if ($catchResult.error.code -eq 'NotFound' -and $catchResult.error.message -like '*returns null or empty list for id*') {
Logging -preventWriteOutput $true -logMessage "$defaultErrorInfo - (plain : $catchResult) - AzAPICall: seems Subscription is not onboarded to CostManagement yet (new/parked subscription) - skipping"
$response = @{
action = 'return' #break or return or returnCollection
returnVar = 'NotFoundNotSupported'
}
return $response
}With that, we ensure that the return is |
|
Hi @JanElholm, Thanks a lot. Cheers, |

Fixes #58.
Problem
New or "parked" subscriptions that Cost Management has not onboarded yet return HTTP 404 with a string-coded
error.codeofNotFound:The CostManagement rule set tolerated the numeric
404("created recently") and two specificNotFoundmessages, but not this one. The call therefore fell through to the genericStophandler and aborted the entire run (observed in Azure Governance Visualizer-DoAzureConsumptionwith a parked CSP subscription).Fix
Treat this
NotFoundmessage like the existing numeric-404 "created recently" case: skip the subscription and return an empty collection (action = 'returnCollection').Changes were made under
pwsh/module/devand the module was rebuilt withbuildModule.ps1 -test, sopwsh/module/buildis regenerated accordingly.Notes