Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unable to cleanup AMBA deployment - Property "Id" cannot be found #475

Closed
1 task done
Greg-Court opened this issue Jan 7, 2025 · 4 comments · Fixed by #474
Closed
1 task done

[Bug]: Unable to cleanup AMBA deployment - Property "Id" cannot be found #475

Greg-Court opened this issue Jan 7, 2025 · 4 comments · Fixed by #474
Assignees
Labels
bug Something isn't working Pattern: ALZ 🚁 Issues / PR's related to the ALZ Pattern

Comments

@Greg-Court
Copy link

Check for previous/existing GitHub issues

  • I have checked for previous/existing GitHub issues

Issue Type?

Bug

Description

Running the following command to cleanup AMBA deployment:

$location = "northeurope"
$pseudoRootManagementGroup = "redacted"

./azure-monitor-baseline-alerts/patterns/alz/scripts/Start-AMBA-ALZ-Maintenance.ps1 -pseudoRootManagementGroup $pseudoRootManagementGroup -cleanItems Amba-Alz -WhatIf -Verbose

Terminal output:

VERBOSE: Populating RepositorySourceLocation property for module Az.Resources.
VERBOSE: Populating RepositorySourceLocation property for module Az.ResourceGraph.
VERBOSE: Populating RepositorySourceLocation property for module Az.ManagedServiceIdentity.

Found '12' management group(s) (including the parent one) which are part of the 'redacted' management group hierarchy, to be queried for AMBA-ALZ resources.

Select-Object: /redacted/azure-monitor-baseline-alerts/patterns/alz/scripts/Start-AMBA-ALZ-Maintenance.ps1:157
Line |
 157 |  … s $managementGroups.mgName | Select-Object -ExpandProperty Id | Sort- …
     |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Property "Id" cannot be found.

Added debugging to the script, it seems there is an issue with batching:

PS /Users/redacted/Projects/redacted/redacted_LZ/AMBA> ./Start-AMBA-ALZ-Maintenance-DEBUG.ps1 -pseudoRootManagementGroup $pseudoRootManagementGroup -cleanItems Amba-Alz -WhatIf -Verbose
VERBOSE: Populating RepositorySourceLocation property for module Az.Resources.
VERBOSE: Populating RepositorySourceLocation property for module Az.ResourceGraph.
VERBOSE: Populating RepositorySourceLocation property for module Az.ManagedServiceIdentity.
DEBUG: About to retrieve all management groups for: redacted
DEBUG: 1 MG(s) returned from Get-AzManagementGroup
DEBUG: Iterating MG redacted
DEBUG: Iterating MG redacted-platform
DEBUG: Iterating MG redacted-management
DEBUG: Iterating MG redacted-connectivity
DEBUG: Iterating MG redacted-identity
DEBUG: Iterating MG redacted-decommissioned
DEBUG: Iterating MG redacted-landing-zones
DEBUG: Iterating MG redacted-corp
DEBUG: Iterating MG redacted-ai
DEBUG: Iterating MG redacted-data
DEBUG: Iterating MG redacted-online
DEBUG: Iterating MG redacted-sandboxes

Found '12' management group(s) (including the parent one) which are part of the 'redacted' management group hierarchy, to be queried for AMBA-ALZ resources.

DEBUG: Full managementGroups array content:

mgName : redacted
mgId   : /providers/Microsoft.Management/managementGroups/redacted

mgName : redacted-platform
mgId   : /providers/Microsoft.Management/managementGroups/redacted-platform

mgName : redacted-management
mgId   : /providers/Microsoft.Management/managementGroups/redacted-management

mgName : redacted-connectivity
mgId   : /providers/Microsoft.Management/managementGroups/redacted-connectivity

mgName : redacted-identity
mgId   : /providers/Microsoft.Management/managementGroups/redacted-identity

mgName : redacted-decommissioned
mgId   : /providers/Microsoft.Management/managementGroups/redacted-decommissioned

mgName : redacted-landing-zones
mgId   : /providers/Microsoft.Management/managementGroups/redacted-landing-zones

mgName : redacted-corp
mgId   : /providers/Microsoft.Management/managementGroups/redacted-corp

mgName : redacted-ai
mgId   : /providers/Microsoft.Management/managementGroups/redacted-ai

mgName : redacted-data
mgId   : /providers/Microsoft.Management/managementGroups/redacted-data

mgName : redacted-online
mgId   : /providers/Microsoft.Management/managementGroups/redacted-online

mgName : redacted-sandboxes
mgId   : /providers/Microsoft.Management/managementGroups/redacted-sandboxes

DEBUG: CleanItems = Amba-Alz
DEBUG: Entering Get-ALZ-Alerts
DEBUG: Query used: Resources | where type in~ ('Microsoft.Insights/metricAlerts','Microsoft.Insights/activityLogAlerts', 'Microsoft.Insights/scheduledQueryRules') and tags['_deployed_by_amba'] =~ 'True' | project id
DEBUG: Entering Search-AzGraphRecursive
DEBUG: Query = Resources | where type in~ ('Microsoft.Insights/metricAlerts','Microsoft.Insights/activityLogAlerts', 'Microsoft.Insights/scheduledQueryRules') and tags['_deployed_by_amba'] =~ 'True' | project id
DEBUG: Management Groups to query = redacted, redacted-platform, redacted-management, redacted-connectivity, redacted-identity, redacted-decommissioned, redacted-landing-zones, redacted-corp, redacted-ai, redacted-data, redacted-online, redacted-sandboxes
DEBUG: More than 10 MGs, batching requests...
DEBUG: Querying batch: redacted, redacted-platform, redacted-management, redacted-connectivity, redacted-identity, redacted-decommissioned, redacted-landing-zones, redacted-corp, redacted-ai, redacted-data
DEBUG: Batch returned 0 items.
DEBUG: Querying batch: redacted-online, redacted-sandboxes
DEBUG: Batch returned 0 items.
DEBUG: Exiting Search-AzGraphRecursive
Select-Object: /Users/redacted/Projects/redacted/redacted_LZ/AMBA/Start-AMBA-ALZ-Maintenance-DEBUG.ps1:178
Line |
 178 |  … s $managementGroups.mgName | Select-Object -ExpandProperty Id | Sort- …
     |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Property "Id" cannot be found.

Issue occurs on main branch at time of writing, and on 2024-12-10 release

@Greg-Court Greg-Court added the Pattern: ALZ 🚁 Issues / PR's related to the ALZ Pattern label Jan 7, 2025
@tagolovina tagolovina added the bug Something isn't working label Jan 8, 2025
@AErmie
Copy link

AErmie commented Jan 9, 2025

This sounds very similar to the issue I reported here: [Question/Feedback]: What is the supported method to update the Action Group Email property?.

I still can't run the Start-AMBA-ALZ-Maintenance.ps1 script. I get the same output of Found '#' management group(s) (including the parent one) which are part of the 'MGMT_GRP' management group hierarchy, to be queried for AMBA-ALZ resources.

Glad to see someone else has the same type of issue.

@tagolovina
Copy link
Contributor

Hello @AErmie , @Greg-Court thanks for your feedback. We have captured this on the backlog and we are working on it.

@tagolovina tagolovina linked a pull request Jan 10, 2025 that will close this issue
@Brunoga-MS
Copy link
Contributor

Hello @AErmie and @Greg-Court ,
we were finally able to repro your issue and to fix it in this release.

Based on that I am going to close this one as resolved.

Feel free to reopen it or create a new one should it be the case.

Thanks,
Bruno and Tanya

@AErmie
Copy link

AErmie commented Jan 10, 2025

@Brunoga-MS, just tested the latest PowerShell script, and confirmed that it's working! Thank you to the team for resolving this!

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Pattern: ALZ 🚁 Issues / PR's related to the ALZ Pattern
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants