Skip to content

[Performance] Get-AzRetirementRecommendation buffers all results instead of streaming #30

@cocallaw

Description

@cocallaw

Summary

Get-AzRetirementRecommendation collects all recommendations into an in-memory List[object] and returns them as an array in the end block, preventing pipeline streaming.

Impact

In large tenants with many subscriptions and recommendations, this delays first output until all subscriptions have been queried and increases peak memory usage.

Location

  • Public/Get-AzRetirementRecommendation.ps1
    • $allRecommendations accumulator: line 41
    • Return in end block: line 351

Suggested fix

Emit each PSCustomObject directly in the process block instead of accumulating. If callers need array output, they can collect with @(Get-AzRetirementRecommendation).

This is a behavioral change (streaming vs. buffered), so it could be offered as an opt-in -Stream switch to maintain backward compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestperformancePerformance improvementpriority: mediumMedium priority — plan for near-term

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions