Skip to content

fix: resolve management group display names to IDs#124

Open
mtellin wants to merge 1 commit into
masterfrom
fix/azure-management-group-name-resolution
Open

fix: resolve management group display names to IDs#124
mtellin wants to merge 1 commit into
masterfrom
fix/azure-management-group-name-resolution

Conversation

@mtellin

@mtellin mtellin commented May 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Search-AzGraph -ManagementGroup requires the group ID (e.g., mg-root), not the display name (e.g., Tenant Root Group)
  • The script now queries Get-AzManagementGroup to resolve display names to IDs before calling Search-AzGraph
  • Falls back to using the input as-is if resolution fails (so existing users passing IDs are unaffected)
  • Updated parameter help to clarify both IDs and display names are accepted

Closes #87

Test plan

  • Run Get-AzureSizingInfo.ps1 -ManagementGroups "Tenant Root Group" — should resolve and succeed
  • Run Get-AzureSizingInfo.ps1 -ManagementGroups "<actual-mg-id>" — should work as before
  • Run with a non-existent name — should fall back and show the original Azure error

🤖 Generated with Claude Code

Search-AzGraph -ManagementGroup requires the group ID, not the display
name. When a user passes a display name like "Tenant Root Group", the
script now queries Get-AzManagementGroup to resolve it to the actual
ID before calling Search-AzGraph. Falls back to using the input as-is
if resolution fails.

Closes #87

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@stevenctong stevenctong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review: the fix correctly resolves management group display names to IDs before calling Search-AzGraph. Backwards compatible — existing users passing IDs are unaffected. Graceful fallback if Get-AzManagementGroup fails. Minor nit: Get-AzManagementGroup is called per loop iteration rather than hoisted, but low impact since this runs once at startup. LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using management groups with Get-AzureSizingInfo.ps1 doesn't work

2 participants