azure-mgmt-costmanagement CostManagementClient ignores nextLink for usage
- Package Name: azure-mgmt-costmanagement
- Package Version: 1.0.0
- Operating System: Linux
- Python Version: 3.7.3
Describe the bug When I invoke CostManagementClient.query.usage() for a query with a lot of results, such as all resource groups or resource IDs for a whole billing month, I get an incomplete result. The SDK ignores nextLink in the result and returns only the first page. Working around this is tricky, because usage() does not accept a next_link or skiptoken argument. I ended up doing something super-hacky: I pass skiptoken as a kwarg to usage() anyway, and when I create the client I add a custom hook to the pipeline that pops skiptoken out of request.context.options and then rewrites request.http_request.url to include the skiptoken. (FWIW, I was rewriting the URL anyway to work around https://github.com/Azure/azure-sdk-for-python/issues/17351)
Examples elided to avoid exposing PII.
@jazelenk Thanks for your report! Directing this to the right people.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ms-premp, @ramaganesan-rg.
Issue Details
- Package Name: azure-mgmt-costmanagement
- Package Version: 1.0.0
- Operating System: Linux
- Python Version: 3.7.3
Describe the bug When I invoke CostManagementClient.query.usage() for a query with a lot of results, such as all resource groups or resource IDs for a whole billing month, I get an incomplete result. The SDK ignores nextLink in the result and returns only the first page. Working around this is tricky, because usage() does not accept a next_link or skiptoken argument. I ended up doing something super-hacky: I pass skiptoken as a kwarg to usage() anyway, and when I create the client I add a custom hook to the pipeline that pops skiptoken out of request.context.options and then rewrites request.http_request.url to include the skiptoken. (FWIW, I was rewriting the URL anyway to work around https://github.com/Azure/azure-sdk-for-python/issues/17351)
Examples elided to avoid exposing PII.
| Author: | jazelenk |
|---|---|
| Assignees: | msyyc |
| Labels: |
|
| Milestone: | - |
It's a Swagger feedback, that don't define the operation as pageable. Tagging service team to fix it.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @TiagoCrewGitHubIssues.
Issue Details
- Package Name: azure-mgmt-costmanagement
- Package Version: 1.0.0
- Operating System: Linux
- Python Version: 3.7.3
Describe the bug When I invoke CostManagementClient.query.usage() for a query with a lot of results, such as all resource groups or resource IDs for a whole billing month, I get an incomplete result. The SDK ignores nextLink in the result and returns only the first page. Working around this is tricky, because usage() does not accept a next_link or skiptoken argument. I ended up doing something super-hacky: I pass skiptoken as a kwarg to usage() anyway, and when I create the client I add a custom hook to the pipeline that pops skiptoken out of request.context.options and then rewrites request.http_request.url to include the skiptoken. (FWIW, I was rewriting the URL anyway to work around https://github.com/Azure/azure-sdk-for-python/issues/17351)
Examples elided to avoid exposing PII.
| Author: | jazelenk |
|---|---|
| Assignees: | msyyc |
| Labels: |
|
| Milestone: | - |
This is not a service issue - this is an SDK update. The customer usage via the SDK/CLI should allow the customer to use the nextLink provided in the first page returned via powershell. Currently there is no parameter support in the CLI to specify the nextLink parameter.

Removed Service label as this is an SDK issue based on comment above and not a service issue. Pls route it to the SDK team
@olsaal-msft @ShilpiGautam I'm sorry but this is a Swagger definition issue. Your payload is highly unusual and does not respect the pageable definition of ARM, therefore you cannot use the x-ms-pageable, you need then to provide an additional operation like Query_UsageNextLink that would take a full url with no parameter and do the call.
SDK creates operations based on Swagger definition, so if you don't define any operation in Swagger that can read a nextLink, there is unfortunately no way for customer to call it.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @TiagoCrewGitHubIssues.
Issue Details
- Package Name: azure-mgmt-costmanagement
- Package Version: 1.0.0
- Operating System: Linux
- Python Version: 3.7.3
Describe the bug When I invoke CostManagementClient.query.usage() for a query with a lot of results, such as all resource groups or resource IDs for a whole billing month, I get an incomplete result. The SDK ignores nextLink in the result and returns only the first page. Working around this is tricky, because usage() does not accept a next_link or skiptoken argument. I ended up doing something super-hacky: I pass skiptoken as a kwarg to usage() anyway, and when I create the client I add a custom hook to the pipeline that pops skiptoken out of request.context.options and then rewrites request.http_request.url to include the skiptoken. (FWIW, I was rewriting the URL anyway to work around https://github.com/Azure/azure-sdk-for-python/issues/17351)
Examples elided to avoid exposing PII.
| Author: | jazelenk |
|---|---|
| Assignees: | msyyc |
| Labels: |
|
| Milestone: | - |
Any news on this bug report?
Hey @ShilpiGautam @olsaal-msft, Would you be able to take a look at the response @lmazuel posted above + respond with any thoughts/updates? Thanks!
I apologize for the inconvenience. Upon further investigation, the API contract and corresponding Swagger do not integrate with the SDK in such a way to allow automatic pagination. We will add this API contract change as a work item into our backlog.
Hi @jazelenk. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.
Hi @jazelenk, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.