Skip to content

Commit fc83f32

Browse files
Merge pull request #333 from microsoft/3.6.9
3.6.9
2 parents dee4de7 + 4b12f9b commit fc83f32

File tree

8 files changed

+106
-61
lines changed

8 files changed

+106
-61
lines changed

AzureResourceInventory.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Claudio Merola
55
#
6-
# Updated on: 04/08/2025
6+
# Updated on: 06/06/2025
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = 'AzureResourceInventory.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '3.6.7'
15+
ModuleVersion = '3.6.9'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

Modules/Private/0.MainFunctions/Start-ARIProcessOrchestration.ps1

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ https://github.com/microsoft/ARI/Modules/Private/0.MainFunctions/Start-ARIProces
1212
This PowerShell Module is part of Azure Resource Inventory (ARI)
1313
1414
.NOTES
15-
Version: 3.6.0
15+
Version: 3.6.9
1616
First Release Date: 15th Oct, 2024
1717
Authors: Claudio Merola
1818
@@ -35,7 +35,7 @@ function Start-ARIProcessOrchestration {
3535
{
3636
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Processing Resources in Automation Mode')
3737

38-
Start-ARIAutProcessJob -Resources $Resources -Retirements $Retirements -Subscriptions $Subscriptions -InTag $InTag -Unsupported $Unsupported
38+
Start-ARIAutProcessJob -Resources $Resources -Retirements $Retirements -Subscriptions $Subscriptions -Heavy $Heavy -InTag $InTag -Unsupported $Unsupported
3939
}
4040
else
4141
{
@@ -48,31 +48,28 @@ function Start-ARIProcessOrchestration {
4848

4949
<############################################################## RESOURCES PROCESSING #############################################################>
5050

51-
if(![string]::IsNullOrEmpty($JobNames))
51+
if ($Automation.IsPresent)
52+
{
53+
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Waiting for Resource Jobs to Complete in Automation Mode')
54+
Get-Job | Where-Object {$_.name -like 'ResourceJob_*'} | Wait-Job
55+
}
56+
else
5257
{
53-
if ($Automation.IsPresent)
54-
{
55-
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Waiting for Resource Jobs to Complete in Automation Mode')
56-
Get-Job | Where-Object {$_.name -like 'ResourceJob_*'} | Wait-Job
57-
}
58-
else
59-
{
60-
$JobNames = (Get-Job | Where-Object {$_.name -like 'ResourceJob_*'}).Name
61-
Wait-ARIJob -JobNames $JobNames -JobType 'Resource' -LoopTime 5
62-
}
63-
64-
if ($Automation.IsPresent)
65-
{
66-
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Processing Resources in Automation Mode')
67-
}
68-
else
69-
{
70-
Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Finished Waiting for Resource Jobs.')
71-
}
72-
73-
Build-ARICacheFiles -DefaultPath $DefaultPath -JobNames $JobNames
58+
$JobNames = (Get-Job | Where-Object {$_.name -like 'ResourceJob_*'}).Name
59+
Wait-ARIJob -JobNames $JobNames -JobType 'Resource' -LoopTime 5
7460
}
7561

62+
if ($Automation.IsPresent)
63+
{
64+
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Processing Resources in Automation Mode')
65+
}
66+
else
67+
{
68+
Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Finished Waiting for Resource Jobs.')
69+
}
70+
71+
Build-ARICacheFiles -DefaultPath $DefaultPath -JobNames $JobNames
72+
7673
Write-Progress -activity 'Azure Inventory' -Status "60% Complete." -PercentComplete 60 -CurrentOperation "Completed Data Processing Phase.."
7774

7875
}

Modules/Private/2.ProcessingFunctions/Start-ARIAutProcessJob.ps1

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ https://github.com/microsoft/ARI/Modules/Private/2.ProcessingFunctions/Start-ARI
1212
This PowerShell Module is part of Azure Resource Inventory (ARI).
1313
1414
.NOTES
15-
Version: 3.6.5
15+
Version: 3.6.9
1616
First Release Date: 15th Oct, 2024
1717
Authors: Claudio Merola
1818
#>
1919

2020
function Start-ARIAutProcessJob {
21-
Param($Resources, $Retirements, $Subscriptions, $InTag, $Unsupported)
21+
Param($Resources, $Retirements, $Subscriptions, $Heavy, $InTag, $Unsupported)
2222

2323
$ParentPath = (get-item $PSScriptRoot).parent.parent
2424
$InventoryModulesPath = Join-Path $ParentPath 'Public' 'InventoryModules'
@@ -27,6 +27,16 @@ function Start-ARIAutProcessJob {
2727
$JobLoop = 1
2828
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+"Starting ARI Automation Processing Jobs...")
2929

30+
if ($Heavy.IsPresent -or $InTag.IsPresent)
31+
{
32+
Write-Output ('Heavy Mode Detected. Jobs will be run in small batches to avoid CPU and Memory Overload.')
33+
$EnvSizeLooper = 2
34+
}
35+
else
36+
{
37+
$EnvSizeLooper = 4
38+
}
39+
3040
Foreach ($ModuleFolder in $Modules)
3141
{
3242
$ModulePath = Join-Path $ModuleFolder.FullName '*.ps1'
@@ -63,7 +73,7 @@ function Start-ARIAutProcessJob {
6373

6474
} -ArgumentList $ModuleFiles, $PSScriptRoot, $Subscriptions, $InTag, $NewResources, $Retirements, 'Processing', $null, $null, $null, $Unsupported | Out-Null
6575

66-
if($JobLoop -eq 4)
76+
if($JobLoop -eq $EnvSizeLooper)
6777
{
6878
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Waiting Batch Jobs')
6979

Modules/Private/3.ReportingFunctions/Build-ARIAdvisoryReport.ps1

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,36 @@ https://github.com/microsoft/ARI/Modules/Private/3.ReportingFunctions/Build-ARIA
1212
This PowerShell Module is part of Azure Resource Inventory (ARI)
1313
1414
.NOTES
15-
Version: 3.6.0
15+
Version: 3.6.9
1616
First Release Date: 15th Oct, 2024
1717
Authors: Claudio Merola
1818
#>
1919

2020
function Build-ARIAdvisoryReport {
2121
param($File, $Adv, $TableStyle)
2222
$condtxtadv = @()
23-
$condtxtadv += New-ConditionalText High -Range E:E
24-
$condtxtadv += New-ConditionalText Security -Range D:D -BackgroundColor Wheat
23+
$condtxtadv += New-ConditionalText High -Range H:H
24+
$condtxtadv += New-ConditionalText Security -Range G:G -BackgroundColor Wheat
2525

26-
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '#,##0.00' -Range H:H
26+
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '#,##0.00' -Range O:O
2727

2828
[PSCustomObject]$Adv |
2929
ForEach-Object { $_ } |
30-
Select-Object 'ResourceGroup',
31-
'Affected Resource Type',
30+
Select-Object 'Subscription',
31+
'Resource Group',
32+
'Resource Type',
3233
'Name',
34+
'Detailed Type',
35+
'Detailed Name',
3336
'Category',
3437
'Impact',
35-
#'Score',
36-
'Problem',
38+
'Description',
39+
'SKU',
40+
'Term',
41+
'Look-back Period',
42+
'Quantity',
3743
'Savings Currency',
3844
'Annual Savings',
39-
'Savings Region',
40-
'Current SKU',
41-
'Target SKU' |
45+
'Savings Region' |
4246
Export-Excel -Path $File -WorksheetName 'Advisor' -AutoSize -MaxAutoSizeRows 100 -TableName 'AzureAdvisory' -MoveToStart -TableStyle $tableStyle -Style $Style -ConditionalText $condtxtadv
4347
}

Modules/Private/3.ReportingFunctions/Start-ARIExcelExtraData.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ https://github.com/microsoft/ARI/Modules/Private/3.ReportingFunctions/Start-ARIE
1212
This PowerShell Module is part of Azure Resource Inventory (ARI)
1313
1414
.NOTES
15-
Version: 3.6.0
15+
Version: 3.6.9
1616
First Release Date: 15th Oct, 2024
1717
Authors: Claudio Merola
1818
#>
@@ -241,7 +241,6 @@ function Start-ARIExcelExtraData {
241241

242242
}
243243

244-
245244
Close-ExcelPackage $excel
246245

247246
}

Modules/Public/PublicFunctions/Invoke-ARI.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ Function Invoke-ARI {
312312

313313
Clear-ARICacheFolder -ReportCache $ReportCache
314314

315+
Get-Job | Where-Object {$_.name -like 'ResourceJob_*'} | Remove-Job -Force | Out-Null
316+
315317
$ExtractionRuntime = [System.Diagnostics.Stopwatch]::StartNew()
316318

317319
$ExtractionData = Start-ARIExtractionOrchestration -ManagementGroup $ManagementGroup -Subscriptions $Subscriptions -SubscriptionID $SubscriptionID -ResourceGroup $ResourceGroup -SecurityCenter $SecurityCenter -SkipAdvisory $SkipAdvisory -SkipPolicy $SkipPolicy -IncludeTags $IncludeTags -TagKey $TagKey -TagValue $TagValue -SkipAPIs $SkipAPIs -SkipVMDetails $SkipVMDetails -IncludeCosts $IncludeCosts -Automation $Automation

Modules/Public/PublicFunctions/Jobs/Start-ARIAdvisoryJob.ps1

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ https://github.com/microsoft/ARI/Modules/Public/PublicFunctions/Jobs/Start-ARIAd
1212
This powershell Module is part of Azure Resource Inventory (ARI)
1313
1414
.NOTES
15-
Version: 3.6.0
15+
Version: 3.6.9
1616
First Release Date: 15th Oct, 2024
1717
Authors: Claudio Merola
1818
@@ -23,23 +23,56 @@ function Start-ARIAdvisoryJob {
2323
$tmp = foreach ($1 in $Advisories)
2424
{
2525
$data = $1.PROPERTIES
26-
$Savings = if([string]::IsNullOrEmpty($data.extendedProperties.annualSavingsAmount)){0}Else{$data.extendedProperties.annualSavingsAmount}
27-
$SavingsCurrency = if([string]::IsNullOrEmpty($data.extendedProperties.savingsCurrency)){'USD'}Else{$data.extendedProperties.savingsCurrency}
28-
$obj = @{
29-
'ResourceGroup' = $1.RESOURCEGROUP;
30-
'Affected Resource Type' = $data.impactedField;
31-
'Name' = $data.impactedValue;
32-
'Category' = $data.category;
33-
'Impact' = $data.impact;
34-
#'Score' = $data.extendedproperties.score;
35-
'Problem' = $data.shortDescription.problem;
36-
'Savings Currency' = $SavingsCurrency;
37-
'Annual Savings' = "=$Savings";
38-
'Savings Region' = $data.extendedProperties.location;
39-
'Current SKU' = $data.extendedProperties.currentSku;
40-
'Target SKU' = $data.extendedProperties.targetSku
41-
}
42-
$obj
26+
27+
if ($data.resourceMetadata.resourceId)
28+
{
29+
$Savings = if([string]::IsNullOrEmpty($data.extendedProperties.annualSavingsAmount)){0}Else{$data.extendedProperties.annualSavingsAmount}
30+
$SavingsCurrency = if([string]::IsNullOrEmpty($data.extendedProperties.savingsCurrency)){'USD'}Else{$data.extendedProperties.savingsCurrency}
31+
$Resource = $data.resourceMetadata.resourceId.split('/')
32+
33+
if ($Resource.Count -lt 4) {
34+
$ResourceType = $data.impactedField
35+
$ResourceName = $data.impactedValue
36+
}
37+
else {
38+
$ResourceType = ($Resource[6] + '/' + $Resource[7])
39+
$ResourceName = $Resource[8]
40+
}
41+
42+
if ($data.impactedField -eq $ResourceType) {
43+
$ImpactedField = ''
44+
}
45+
else {
46+
$ImpactedField = $data.impactedField
47+
}
48+
49+
if ($data.impactedValue -eq $ResourceName) {
50+
$ImpactedValue = ''
51+
}
52+
else {
53+
$ImpactedValue = $data.impactedValue
54+
}
55+
56+
$obj = @{
57+
'Subscription' = $Resource[2];
58+
'Resource Group' = $Resource[4];
59+
'Resource Type' = $ResourceType;
60+
'Name' = $ResourceName;
61+
'Detailed Type' = $ImpactedField;
62+
'Detailed Name' = $ImpactedValue;
63+
'Category' = $data.category;
64+
'Impact' = $data.impact;
65+
'Description' = $data.shortDescription.problem;
66+
'SKU' = $data.extendedProperties.sku;
67+
'Term' = $data.extendedProperties.term;
68+
'Look-back Period' = $data.extendedProperties.lookbackPeriod;
69+
'Quantity' = $data.extendedProperties.qty;
70+
'Savings Currency' = $SavingsCurrency;
71+
'Annual Savings' = "=$Savings";
72+
'Savings Region' = $data.extendedProperties.region
73+
}
74+
$obj
75+
}
4376
}
4477
$tmp
4578
}

SUPPORT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ This project uses GitHub Issues to track bugs, feature requests, and questions.
3636

3737
Official support for this project is limited to the GitHub issues system as described above.
3838

39-
> **Note**: Azure Resource Inventory is an open-source project maintained by Microsoft. While we strive to address issues in a timely manner, response times may vary based on priority and maintainer availability.
39+
> **Note**: Azure Resource Inventory is an open-source project maintained by the community. While we strive to address issues in a timely manner, response times may vary based on priority and maintainer availability. Microsoft offers no official support for this project.
4040
4141
## 🔄 Issue Lifecycle
4242

0 commit comments

Comments
 (0)