Skip to content

Commit 9694ae5

Browse files
Merge pull request #227 from JanElholm/doazureconsumptionpreviousmonth
Added support for -DoAzureConsumptionPreviousMonth
2 parents 6905e6f + f4e9e66 commit 9694ae5

File tree

7 files changed

+169
-142
lines changed

7 files changed

+169
-142
lines changed

.azuredevops/pipelines/AzGovViz.variables.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ variables:
147147
# Integer | default = 1 | example: value: 7
148148
value: 14
149149

150+
# Define if Azure Consumption data should be reported for previous month
151+
- name: DoAzureConsumptionPreviousMonth
152+
# Switch | example: value: true
153+
value:
154+
150155
# Do not include Role assignments on ResourceGroups and Resources
151156
- name: DoNotIncludeResourceGroupsAndResourcesOnRBAC
152157
# Switch | example: value: true

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ Screenshot of Microsoft Graph permissions in the Microsoft Entra admin center
509509
* ~~`-ServicePrincipalExpiryWarningDays`~~ `-AADServicePrincipalExpiryWarningDays` - Define warning period for Service Principal secret and certificate expiry; default is 14 days
510510
* ~~`-NoAzureConsumption`~~ - Azure Consumption data should not be collected/reported
511511
* `-DoAzureConsumption` - Azure Consumption data should be collected/reported
512+
* `-DoAzureConsumptionPreviousMonth` - Azure Consumption data should be collected/reported for the previous month
512513
* `-AzureConsumptionPeriod` - Define for which time period Azure Consumption data should be gathered; default is 1 day
513514
* `-NoAzureConsumptionReportExportToCSV` - Azure Consumption data should not be exported (CSV)
514515
* `-NoScopeInsights` - Q: Why would you want to do this? A: In larger tenants the ScopeInsights section blows up the html file (up to unusable due to html file size). Use `-LargeTenant` to further reduce the output.
@@ -798,3 +799,4 @@ Also check <https://aka.ms/AzADServicePrincipalInsights> - What about your Micro
798799
## Closing Note
799800

800801
Please note that while being developed by a Microsoft employee, Azure Governance Visualizer is not a Microsoft service or product. Azure Governance Visualizer is a personal/community driven project, there are no implicit or explicit obligations related to this project, it is provided 'as is' with no warranties and confer no rights.
802+

history.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
### Azure Governance Visualizer version 6
66

7+
__Changes__ (2024-Mar-14 / 6.4.3 Minor)
8+
9+
* Support for `-DoAzureConsumptionPreviousMonth` - Azure Consumption data should be collected/reported for the previous month
10+
711
__Changes__ (2024-Mar-14 / 6.4.2 Minor)
812

913
* optimize objects handling / best practices

pwsh/AzGovVizParallel.ps1

Lines changed: 147 additions & 139 deletions
Large diffs are not rendered by default.

pwsh/dev/devAzGovVizParallel.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ Param
365365
$Product = 'AzGovViz',
366366

367367
[string]
368-
$ProductVersion = '6.4.2',
368+
$ProductVersion = '6.4.3',
369369

370370
[string]
371371
$GithubRepository = 'aka.ms/AzGovViz',
@@ -454,6 +454,9 @@ Param
454454
[switch]
455455
$DoAzureConsumption,
456456

457+
[switch]
458+
$DoAzureConsumptionPreviousMonth,
459+
457460
[int]
458461
$AzureConsumptionPeriod = 1,
459462

@@ -938,6 +941,10 @@ if (-not $HierarchyMapOnly) {
938941
$arrayTotalCostSummary = @()
939942
$azureConsumptionStartDate = ((Get-Date).AddDays( - ($($AzureConsumptionPeriod)))).ToString('yyyy-MM-dd')
940943
$azureConsumptionEndDate = ((Get-Date).AddDays(-1)).ToString('yyyy-MM-dd')
944+
if ($azAPICallConf['htParameters'].DoAzureConsumptionPreviousMonth -eq $true) {
945+
$azureConsumptionStartDate = ((Get-Date).AddMonths(-1).AddDays( - $((Get-Date).Day) + 1)).ToString('yyyy-MM-dd')
946+
$azureConsumptionEndDate = ((Get-Date).AddDays( - $((Get-Date).Day))).ToString('yyyy-MM-dd')
947+
}
941948
}
942949
$customDataCollectionDuration = [System.Collections.ArrayList]::Synchronized((New-Object System.Collections.ArrayList))
943950
$htResourceLocks = [System.Collections.Hashtable]::Synchronized((New-Object System.Collections.Hashtable)) #@{}

pwsh/dev/functions/addHtParameters.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function addHtParameters {
1717

1818
$script:azAPICallConf['htParameters'] += [ordered]@{
1919
DoAzureConsumption = [bool]$DoAzureConsumption
20+
DoAzureConsumptionPreviousMonth = [bool]$DoAzureConsumptionPreviousMonth
2021
DoNotIncludeResourceGroupsOnPolicy = [bool]$DoNotIncludeResourceGroupsOnPolicy
2122
DoNotIncludeResourceGroupsAndResourcesOnRBAC = [bool]$DoNotIncludeResourceGroupsAndResourcesOnRBAC
2223
DoNotShowRoleAssignmentsUserData = [bool]$DoNotShowRoleAssignmentsUserData

version.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{
2-
"ProductVersion": "6.4.2"
1+
{
2+
"ProductVersion": "6.4.3"
33
}

0 commit comments

Comments
 (0)