azbrowse icon indicating copy to clipboard operation
azbrowse copied to clipboard

Fix subscription pagination to display all available subscriptions

Open Copilot opened this issue 11 months ago • 0 comments

Problem

When a tenant has many subscriptions, Azure returns paginated results with a nextLink property in the API response. Currently, azbrowse only processes the first page of results, causing some subscriptions to be missing from the interface.

Changes

This PR implements support for pagination when listing subscriptions:

  1. Added the NextLink field to the SubResponse struct to capture the pagination URL
  2. Created a new getSubscriptionsWithPaging method that:
    • Makes the initial request to /subscriptions?api-version=2018-01-01
    • Checks if the response contains a nextLink property
    • If present, follows all nextLink URLs recursively until all pages are fetched
    • Aggregates all subscription data into a unified response
  3. Updated the TenantExpander.Expand() method to use this pagination-aware approach
  4. Improved error handling by using the %w verb for proper error wrapping

Testing

The changes were built and verified to compile successfully. The implementation maintains compatibility with existing tests and preserves the behavior for tenants with fewer subscriptions.

Before this change, users with many subscriptions would only see a subset of them. After this change, all subscriptions from all pages will be properly displayed.

Fixes #591.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar May 27 '25 17:05 Copilot