From f56ab31fe8268982a23c6b9d79ef7b504049a9dc Mon Sep 17 00:00:00 2001 From: JulianHayward Date: Mon, 15 Jul 2024 22:11:15 +0200 Subject: [PATCH] 6.4.12; azAPICall 1.2.3 --- README.md | 3 ++- history.md | 3 ++- pwsh/AzGovVizParallel.ps1 | 20 +++++++++++++++----- pwsh/dev/devAzGovVizParallel.ps1 | 4 ++-- pwsh/dev/functions/getConsumptionv2.ps1 | 16 +++++++++++++--- version.json | 2 +- 6 files changed, 35 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9d0f4f5b..a708cac1 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ The [Azure Governance Visualizer accelerator](https://github.com/Azure/Azure-Gov ## Release history -**Changes** (2024-July-15 / 6.4.11 Minor) +**Changes** (2024-July-15 / 6.4.12 Minor) - ALZ policy refresh H2 FY24 (initiatives.json) - [DevSkim](https://github.com/microsoft/DevSkim-Action), [PSScriptAnalyzer](https://github.com/microsoft/psscriptanalyzer-action) and [OpenSSF Scorecard](https://github.com/ossf/scorecard?tab=readme-ov-file#scorecard-github-action) integration @@ -94,6 +94,7 @@ The [Azure Governance Visualizer accelerator](https://github.com/Azure/Azure-Gov - update getConsumption (experimental for now): instead of full Management Group scope costmanagement data retrieval, batch by Subscription quotaId in batches of 100. Failing batches and batches of Subscriptions of quotaId `CSP_2015-05-01` (see param block variable `SubscriptionQuotaIdsThatDoNotSupportCostManagementManagementGroupScopeQuery`) will fallback to get costmanagement data per Subscription. In order to use this you must update the AzGovVizParallel.ps1 file to use the function `getConsumptionv2` instead of `getConsumption` - html; update jquery; source tablefilter js - update `.devcontainer/devcontainer.json` +- use [AzAPICall](https://aka.ms/AzAPICall) PowerShell module version 1.2.3 (Handle costManagement error `SubscriptionCostDisabled`) [Full release history](history.md) diff --git a/history.md b/history.md index b1ebbc7a..ae55fa80 100644 --- a/history.md +++ b/history.md @@ -4,7 +4,7 @@ ### Azure Governance Visualizer version 6 -**Changes** (2024-July-15 / 6.4.11 Minor) +**Changes** (2024-July-15 / 6.4.12 Minor) - ALZ policy refresh H2 FY24 (initiatives.json) - [DevSkim](https://github.com/microsoft/DevSkim-Action), [PSScriptAnalyzer](https://github.com/microsoft/psscriptanalyzer-action) and [OpenSSF Scorecard](https://github.com/ossf/scorecard?tab=readme-ov-file#scorecard-github-action) integration @@ -16,6 +16,7 @@ - update getConsumption (experimental for now): instead of full Management Group scope costmanagement data retrieval, batch by Subscription quotaId in batches of 100. Failing batches and batches of Subscriptions of quotaId `CSP_2015-05-01` (see param block variable `SubscriptionQuotaIdsThatDoNotSupportCostManagementManagementGroupScopeQuery`) will fallback to get costmanagement data per Subscription. In order to use this you must update the AzGovVizParallel.ps1 file to use the function `getConsumptionv2` instead of `getConsumption` - html; update jquery; source tablefilter js - update `.devcontainer/devcontainer.json` +- use [AzAPICall](https://aka.ms/AzAPICall) PowerShell module version 1.2.3 (Handle costManagement error `SubscriptionCostDisabled`) **Changes** (2024-May-05 / 6.4.5 Minor) diff --git a/pwsh/AzGovVizParallel.ps1 b/pwsh/AzGovVizParallel.ps1 index 0d0a3d49..1ad15d61 100644 --- a/pwsh/AzGovVizParallel.ps1 +++ b/pwsh/AzGovVizParallel.ps1 @@ -365,14 +365,14 @@ Param $Product = 'AzGovViz', [string] - $ProductVersion = '6.4.11', + $ProductVersion = '6.4.12', [string] $GithubRepository = 'aka.ms/AzGovViz', # <--- AzAPICall related parameters #consult the AzAPICall GitHub repository for details aka.ms/AzAPICall [string] - $AzAPICallVersion = '1.2.1', + $AzAPICallVersion = '1.2.3', [switch] $DebugAzAPICall, @@ -3566,7 +3566,17 @@ function getConsumptionv2 { } $subConsumptionData = AzAPICall @subConsumptionDataParametersSplat - if ($subConsumptionData -eq 'Unauthorized' -or $subConsumptionData -eq 'OfferNotSupported' -or $subConsumptionData -eq 'InvalidQueryDefinition' -or $subConsumptionData -eq 'NonValidWebDirectAIRSOfferType' -or $subConsumptionData -eq 'NotFoundNotSupported' -or $subConsumptionData -eq 'IndirectCostDisabled') { + $subscriptionScopeKnownErrors = @( + 'Unauthorized', + 'OfferNotSupported', + 'InvalidQueryDefinition', + 'NonValidWebDirectAIRSOfferType', + 'NotFoundNotSupported', + 'IndirectCostDisabled', + 'SubscriptionCostDisabled' + ) + + if ($subConsumptionData -in $subscriptionScopeKnownErrors) { Write-Host " Failed ($subConsumptionData) - Getting Consumption data scope Sub (Subscription: $($subNameToProcess) '$($subIdToProcess)' QuotaId '$($subQuotaId)')" $hlper = $htAllSubscriptionsFromAPI.($subIdToProcess).subDetails $hlper2 = $htSubscriptionsMgPath.($subIdToProcess) @@ -3583,7 +3593,7 @@ function getConsumptionv2 { } else { Write-Host " $($subConsumptionData.properties.rows.Count) Consumption data entries (scope Sub $($subNameToProcess) '$($subIdToProcess)')" - if ($subConsumptionData.Count -gt 0) { + if ($subConsumptionData.properties.rows.Count -gt 0) { addToAllConsumptionData -consumptiondataFromAPI $subConsumptionData -subscriptionQuotaId $subQuotaId } } @@ -3591,7 +3601,7 @@ function getConsumptionv2 { } else { Write-Host " #batch$($batchCnt)/$(($subscriptionsBatch | Measure-Object).Count) for $($batch.Group.Count) Subscriptions of QuotaId '$($quotaIdGroup.Name)' returned $($mgConsumptionData.properties.rows.Count) Consumption data entries" - if ($mgConsumptionData.Count -gt 0) { + if ($mgConsumptionData.properties.rows.Count -gt 0) { addToAllConsumptionData -consumptiondataFromAPI $mgConsumptionData -subscriptionQuotaId $quotaIdGroup.Name } } diff --git a/pwsh/dev/devAzGovVizParallel.ps1 b/pwsh/dev/devAzGovVizParallel.ps1 index 01d0267b..e05a11d9 100644 --- a/pwsh/dev/devAzGovVizParallel.ps1 +++ b/pwsh/dev/devAzGovVizParallel.ps1 @@ -365,14 +365,14 @@ Param $Product = 'AzGovViz', [string] - $ProductVersion = '6.4.11', + $ProductVersion = '6.4.12', [string] $GithubRepository = 'aka.ms/AzGovViz', # <--- AzAPICall related parameters #consult the AzAPICall GitHub repository for details aka.ms/AzAPICall [string] - $AzAPICallVersion = '1.2.1', + $AzAPICallVersion = '1.2.3', [switch] $DebugAzAPICall, diff --git a/pwsh/dev/functions/getConsumptionv2.ps1 b/pwsh/dev/functions/getConsumptionv2.ps1 index 7fa0df7c..378952af 100644 --- a/pwsh/dev/functions/getConsumptionv2.ps1 +++ b/pwsh/dev/functions/getConsumptionv2.ps1 @@ -226,7 +226,17 @@ } $subConsumptionData = AzAPICall @subConsumptionDataParametersSplat - if ($subConsumptionData -eq 'Unauthorized' -or $subConsumptionData -eq 'OfferNotSupported' -or $subConsumptionData -eq 'InvalidQueryDefinition' -or $subConsumptionData -eq 'NonValidWebDirectAIRSOfferType' -or $subConsumptionData -eq 'NotFoundNotSupported' -or $subConsumptionData -eq 'IndirectCostDisabled') { + $subscriptionScopeKnownErrors = @( + 'Unauthorized', + 'OfferNotSupported', + 'InvalidQueryDefinition', + 'NonValidWebDirectAIRSOfferType', + 'NotFoundNotSupported', + 'IndirectCostDisabled', + 'SubscriptionCostDisabled' + ) + + if ($subConsumptionData -in $subscriptionScopeKnownErrors) { Write-Host " Failed ($subConsumptionData) - Getting Consumption data scope Sub (Subscription: $($subNameToProcess) '$($subIdToProcess)' QuotaId '$($subQuotaId)')" $hlper = $htAllSubscriptionsFromAPI.($subIdToProcess).subDetails $hlper2 = $htSubscriptionsMgPath.($subIdToProcess) @@ -243,7 +253,7 @@ } else { Write-Host " $($subConsumptionData.properties.rows.Count) Consumption data entries (scope Sub $($subNameToProcess) '$($subIdToProcess)')" - if ($subConsumptionData.Count -gt 0) { + if ($subConsumptionData.properties.rows.Count -gt 0) { addToAllConsumptionData -consumptiondataFromAPI $subConsumptionData -subscriptionQuotaId $subQuotaId } } @@ -251,7 +261,7 @@ } else { Write-Host " #batch$($batchCnt)/$(($subscriptionsBatch | Measure-Object).Count) for $($batch.Group.Count) Subscriptions of QuotaId '$($quotaIdGroup.Name)' returned $($mgConsumptionData.properties.rows.Count) Consumption data entries" - if ($mgConsumptionData.Count -gt 0) { + if ($mgConsumptionData.properties.rows.Count -gt 0) { addToAllConsumptionData -consumptiondataFromAPI $mgConsumptionData -subscriptionQuotaId $quotaIdGroup.Name } } diff --git a/version.json b/version.json index 1b1373f4..7b01e3ad 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "ProductVersion": "6.4.11" + "ProductVersion": "6.4.12" } \ No newline at end of file