JulianHayward / Azure-MG-Sub-Governance-Reporting

Azure Governance Visualizer aka AzGovViz is a PowerShell script that captures Azure Governance related information such as Azure Policy, RBAC (a lot more) by polling Azure ARM, Storage and Microsoft Graph APIs.
MIT License
845 stars 304 forks source link

Subscription Details is not retrieved for CSP_2015-05-01 subscriptions if tenant has MSDN_2014-09-01 subscriptions #238

Closed ReneRebsdorf closed 1 month ago

ReneRebsdorf commented 3 months ago

AzGovViz version master branch commit 69e5b56

CodeRunPlatform Azure DevOps

Describe the bug For a management group with two different subscriptions of type MSDN & CSP, we will successfully get data when quering the management group for cost details, as it will return it for the MSDN subscription. It will however not return the data for the CSP subscription.

In discussion Julian suggested batching in grouped by quotaId - and as last option foreach subscription For a quick workaround I suggested implementing a forceForEachSubscriptionMode parameter, but I agree that batching by quotaId would definately be better, as it allows for batching as much as possible in fewer REST calls.

The unreviewed code for forceForEachSubscriptionMode:

193:                 .PARAMETER forceForEachSubscriptionMode
    Use this parameter if you want to force the script to run in a foreach Subscription mode.
    This is useful if the tenant has a mixture of subscriptions types, where some do not support providing cost data at
    the management group level (e.g. CSP Subscriptions).

...

2821:                if ($mgConsumptionData -eq 'Unauthorized' -or $mgConsumptionData -eq 'OfferNotSupported' -or $mgConsumptionData -eq 'NoValidSubscriptions' -or $forceForEachSubscriptionMode) {

...

3021:                              if ($allConsumptionDataAPIResult -eq 'Unauthorized' -or $allConsumptionDataAPIResult -eq 'OfferNotSupported' -or $allConsumptionDataAPIResult -eq 'NoValidSubscriptions' -or $allConsumptionDataAPIResult -eq 'tooManySubscriptions' -or $forceForEachSubscriptionMode) {
JulianHayward commented 3 months ago

@ReneRebsdorf please check the dev branch and follow the release notes guidance to test the discussed approach for consumption data

ReneRebsdorf commented 3 months ago

Worked with Julian on a call, issue is still present I will hopefully have time next week to look into this, and suggest a fix.

JulianHayward commented 1 month ago

@ReneRebsdorf main problem should be solved - good to close?

ReneRebsdorf commented 1 month ago

I will check against main next week, but should be good 😊

ReneRebsdorf commented 1 month ago

LGTM - Verified working with a mixture of MSDN and CSP subscriptions