Fix subscription pagination to display all available subscriptions
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:
- Added the
NextLinkfield to theSubResponsestruct to capture the pagination URL - Created a new
getSubscriptionsWithPagingmethod that:- Makes the initial request to
/subscriptions?api-version=2018-01-01 - Checks if the response contains a
nextLinkproperty - If present, follows all
nextLinkURLs recursively until all pages are fetched - Aggregates all subscription data into a unified response
- Makes the initial request to
- Updated the
TenantExpander.Expand()method to use this pagination-aware approach - Improved error handling by using the
%wverb 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.