Skip to content

Commit

Permalink
Merge pull request #225 from JulianHayward/optParallel
Browse files Browse the repository at this point in the history
6.4.1
  • Loading branch information
JulianHayward authored Mar 16, 2024
2 parents 6dd4712 + 7caddbf commit 971553a
Show file tree
Hide file tree
Showing 23 changed files with 763 additions and 573 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ As an alternative, you can use the [Azure Governance Visualizer accelerator](htt

## Release history

__Changes__ (2024-Mar-14 / 6.4.1 Minor)

* optimize objects handling / best practices

__Changes__ (2024-Feb-06 / 6.4.0 Minor)

* change PowerShell parallel handling / batches
Expand Down
4 changes: 4 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

### Azure Governance Visualizer version 6

__Changes__ (2024-Mar-14 / 6.4.1 Minor)

* optimize objects handling / best practices

__Changes__ (2024-Feb-06 / 6.4.0 Minor)

* change PowerShell parallel handling / batches
Expand Down
663 changes: 377 additions & 286 deletions pwsh/AzGovVizParallel.ps1

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pwsh/dev/devAzGovVizParallel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ Param
$Product = 'AzGovViz',

[string]
$ProductVersion = '6.4.0',
$ProductVersion = '6.4.1',

[string]
$GithubRepository = 'aka.ms/AzGovViz',
Expand Down Expand Up @@ -1155,7 +1155,7 @@ if (-not $HierarchyMapOnly) {

#region Getting Available Private Endpoint Types
$startGetAvailablePrivateEndpointTypes = Get-Date

$privateEndpointAvailabilityCheckCompleted = $false
$subsToProcessForGettingPrivateEndpointTypes = [System.Collections.ArrayList]@()
$prioCounter = 0
foreach ($subscription in $subsToProcessInCustomDataCollection) {
Expand Down
172 changes: 90 additions & 82 deletions pwsh/dev/functions/cacheBuiltIn.ps1

Large diffs are not rendered by default.

84 changes: 48 additions & 36 deletions pwsh/dev/functions/dataCollection/dataCollectionFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,9 @@ function dataCollectionResources {

foreach ($resourceType in ($resourcesSubscriptionResult | Group-Object -Property type)) {
if (-not $htResourceTypesUniqueResource.(($resourceType.name).ToLower())) {
$script:htResourceTypesUniqueResource.(($resourceType.name).ToLower()) = @{}
$script:htResourceTypesUniqueResource.(($resourceType.name).ToLower()).resourceId = $resourceType.Group.Id | Select-Object -First 1
$script:htResourceTypesUniqueResource.(($resourceType.name).ToLower()) = @{
resourceId = $resourceType.Group.Id | Select-Object -First 1
}
}
}

Expand Down Expand Up @@ -1319,8 +1320,9 @@ function dataCollectionResources {


#resourceTags
$script:htSubscriptionTagList.($scopeId) = @{}
$script:htSubscriptionTagList.($scopeId).Resource = @{}
$script:htSubscriptionTagList.($scopeId) = @{
Resource = @{}
}
foreach ($tags in ($resourcesSubscriptionResult.where( { $_.Tags -and -not [String]::IsNullOrWhiteSpace($_.Tags) } )).Tags) {
foreach ($tagName in $tags.PSObject.Properties.Name) {
#resource
Expand Down Expand Up @@ -1601,9 +1603,11 @@ function dataCollectionTags {
$subscriptionTagsCount = 0
$subscriptionTags = 'none'
}
$htSubscriptionTagsReturn = @{}
$htSubscriptionTagsReturn.subscriptionTagsCount = $subscriptionTagsCount
$htSubscriptionTagsReturn.subscriptionTags = $subscriptionTags
$htSubscriptionTagsReturn = @{
subscriptionTagsCount = $subscriptionTagsCount
subscriptionTags = $subscriptionTags
}

return $htSubscriptionTagsReturn
}
$funcDataCollectionTags = $function:dataCollectionTags.ToString()
Expand Down Expand Up @@ -1863,7 +1867,7 @@ function dataCollectionBluePrintAssignmentsSub {
foreach ($subscriptionBlueprintAssignment in $subscriptionBlueprintAssignmentsResult) {

if (-not ($htCacheAssignmentsBlueprint).($subscriptionBlueprintAssignment.Id)) {
($script:htCacheAssignmentsBlueprint).($subscriptionBlueprintAssignment.Id) = @{}
#($script:htCacheAssignmentsBlueprint).($subscriptionBlueprintAssignment.Id) = @{}
($script:htCacheAssignmentsBlueprint).($subscriptionBlueprintAssignment.Id) = $subscriptionBlueprintAssignment
}

Expand Down Expand Up @@ -2191,13 +2195,14 @@ function dataCollectionPolicyDefinitions {
foreach ($roledefinitionId in $scopePolicyDefinition.properties.policyRule.then.details.roleDefinitionIds) {
if (-not [string]::IsNullOrEmpty($roledefinitionId)) {
if (-not $htRoleDefinitionIdsUsedInPolicy.($roledefinitionId)) {
$script:htRoleDefinitionIdsUsedInPolicy.($roledefinitionId) = @{}
$script:htRoleDefinitionIdsUsedInPolicy.($roledefinitionId).UsedInPolicies = [System.Collections.ArrayList]@()
$null = $script:htRoleDefinitionIdsUsedInPolicy.($roledefinitionId).UsedInPolicies.Add($hlpPolicyDefinitionId)
}
else {
$script:htRoleDefinitionIdsUsedInPolicy.($roledefinitionId).UsedInPolicies.Add($hlpPolicyDefinitionId)
$script:htRoleDefinitionIdsUsedInPolicy.($roledefinitionId) = @{
UsedInPolicies = [System.Collections.ArrayList]@()
}
#$null = $script:htRoleDefinitionIdsUsedInPolicy.($roledefinitionId).UsedInPolicies.Add($hlpPolicyDefinitionId)
}
#else {
$script:htRoleDefinitionIdsUsedInPolicy.($roledefinitionId).UsedInPolicies.Add($hlpPolicyDefinitionId)
#}
}
else {
Write-Host "$currentTask $($hlpPolicyDefinitionId) Finding: empty roleDefinitionId in roledefinitionIds"
Expand Down Expand Up @@ -3499,26 +3504,29 @@ function dataCollectionRoleDefinitions {
$roleCapable4RoleAssignmentsWrite = $false
}

$htTemp = @{}
$htTemp.Id = $($scopeCustomRoleDefinition.name)
$htTemp.Name = $($scopeCustomRoleDefinition.properties.roleName)
$htTemp.IsCustom = $true
$htTemp.AssignableScopes = $($scopeCustomRoleDefinition.properties.AssignableScopes)
$htTemp.Actions = $($scopeCustomRoleDefinition.properties.permissions.Actions)
$htTemp.NotActions = $($scopeCustomRoleDefinition.properties.permissions.NotActions)
$htTemp.DataActions = $($scopeCustomRoleDefinition.properties.permissions.DataActions)
$htTemp.NotDataActions = $($scopeCustomRoleDefinition.properties.permissions.NotDataActions)
$htTemp.Json = $scopeCustomRoleDefinition
$htTemp.RoleCanDoRoleAssignments = $roleCapable4RoleAssignmentsWrite
$htTemp = @{
Id = $($scopeCustomRoleDefinition.name)
Name = $($scopeCustomRoleDefinition.properties.roleName)
IsCustom = $true
AssignableScopes = $($scopeCustomRoleDefinition.properties.AssignableScopes)
Actions = $($scopeCustomRoleDefinition.properties.permissions.Actions)
NotActions = $($scopeCustomRoleDefinition.properties.permissions.NotActions)
DataActions = $($scopeCustomRoleDefinition.properties.permissions.DataActions)
NotDataActions = $($scopeCustomRoleDefinition.properties.permissions.NotDataActions)
Json = $scopeCustomRoleDefinition
RoleCanDoRoleAssignments = $roleCapable4RoleAssignmentsWrite
}

($script:htCacheDefinitionsRole).($scopeCustomRoleDefinition.name) = $htTemp

#namingValidation
if (-not [string]::IsNullOrEmpty($scopeCustomRoleDefinition.properties.roleName)) {
$namingValidationResult = NamingValidation -toCheck $scopeCustomRoleDefinition.properties.roleName
if ($namingValidationResult.Count -gt 0) {
$script:htNamingValidation.Role.($scopeCustomRoleDefinition.name) = @{}
$script:htNamingValidation.Role.($scopeCustomRoleDefinition.name).roleNameInvalidChars = ($namingValidationResult -join '')
$script:htNamingValidation.Role.($scopeCustomRoleDefinition.name).roleName = $scopeCustomRoleDefinition.properties.roleName
$script:htNamingValidation.Role.($scopeCustomRoleDefinition.name) = @{
roleNameInvalidChars = ($namingValidationResult -join '')
roleName = $scopeCustomRoleDefinition.properties.roleName
}
}
}
}
Expand Down Expand Up @@ -3584,8 +3592,9 @@ function dataCollectionRoleAssignmentsMG {

$L0mgmtGroupRoleAssignmentsLimitUtilization = (($L0mgmtGroupRoleAssignments.properties.where( { $_.scope -eq "/providers/Microsoft.Management/managementGroups/$($scopeId)" } ))).count
if (-not $htMgAtScopeRoleAssignments.($scopeId)) {
$script:htMgAtScopeRoleAssignments.($scopeId) = @{}
$script:htMgAtScopeRoleAssignments.($scopeId).AssignmentsCount = $L0mgmtGroupRoleAssignmentsLimitUtilization
$script:htMgAtScopeRoleAssignments.($scopeId) = @{
AssignmentsCount = $L0mgmtGroupRoleAssignmentsLimitUtilization
}
}

if ($azAPICallConf['htParameters'].LargeTenant -eq $true -or $azAPICallConf['htParameters'].RBACAtScopeOnly -eq $true) {
Expand All @@ -3595,8 +3604,9 @@ function dataCollectionRoleAssignmentsMG {
#tenantLevelRoleAssignments
if (-not $htMgAtScopeRoleAssignments.'tenantLevelRoleAssignments') {
$tenantLevelRoleAssignmentsCount = (($L0mgmtGroupRoleAssignments.where( { $_.id -like '/providers/Microsoft.Authorization/roleAssignments/*' } ))).count
$script:htMgAtScopeRoleAssignments.'tenantLevelRoleAssignments' = @{}
$script:htMgAtScopeRoleAssignments.'tenantLevelRoleAssignments'.AssignmentsCount = $tenantLevelRoleAssignmentsCount
$script:htMgAtScopeRoleAssignments.'tenantLevelRoleAssignments' = @{
AssignmentsCount = $tenantLevelRoleAssignmentsCount
}
}
}
foreach ($L0mgmtGroupRoleAssignment in $L0mgmtGroupRoleAssignments) {
Expand All @@ -3622,8 +3632,9 @@ function dataCollectionRoleAssignmentsMG {
}

if (-not $htRoleAssignmentsFromAPIInheritancePrevention.($roleAssignmentId -replace '.*/')) {
$script:htRoleAssignmentsFromAPIInheritancePrevention.($roleAssignmentId -replace '.*/') = @{}
$script:htRoleAssignmentsFromAPIInheritancePrevention.($roleAssignmentId -replace '.*/').assignment = $L0mgmtGroupRoleAssignment
$script:htRoleAssignmentsFromAPIInheritancePrevention.($roleAssignmentId -replace '.*/') = @{
assignment = $L0mgmtGroupRoleAssignment
}
}

$roleDefinitionId = $L0mgmtGroupRoleAssignment.properties.roleDefinitionId
Expand Down Expand Up @@ -4182,8 +4193,9 @@ function dataCollectionClassicAdministratorsSub {
})
}
}
$script:htClassicAdministrators.($scopeId) = @{}
$script:htClassicAdministrators.($scopeId).ClassicAdministrators = $arrayClassicAdministrators
$script:htClassicAdministrators.($scopeId) = @{
ClassicAdministrators = $arrayClassicAdministrators
}
}
}
$funcDataCollectionClassicAdministratorsSub = $function:dataCollectionClassicAdministratorsSub.ToString()
Expand Down
Loading

0 comments on commit 971553a

Please sign in to comment.