azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

azure-mgmt-costmanagement CostManagementClient ignores nextLink for usage

Open jazelenk opened this issue 5 years ago • 13 comments

  • 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 avatar May 25 '21 17:05 jazelenk

@jazelenk Thanks for your report! Directing this to the right people.

swathipil avatar May 26 '21 14:05 swathipil

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:

Cost Management, Mgmt, Service Attention, bug

Milestone: -

ghost avatar Jun 08 '21 17:06 ghost

It's a Swagger feedback, that don't define the operation as pageable. Tagging service team to fix it.

lmazuel avatar Jun 08 '21 17:06 lmazuel

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:

Cost Management, Cost Management-UsageDetailsAndExport, Mgmt, Service Attention, bug

Milestone: -

ghost avatar Jul 08 '21 00:07 ghost

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.

image

olsaal-msft avatar Jul 13 '21 17:07 olsaal-msft

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

ShilpiGautam avatar Jul 13 '21 17:07 ShilpiGautam

@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.

lmazuel avatar Aug 18 '21 15:08 lmazuel

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:

bug, Service Attention, Mgmt, Cost Management-UsageDetailsAndExport

Milestone: -

ghost avatar Aug 18 '21 15:08 ghost

Any news on this bug report?

jbvsmo avatar Sep 30 '21 17:09 jbvsmo

Hey @ShilpiGautam @olsaal-msft, Would you be able to take a look at the response @lmazuel posted above + respond with any thoughts/updates? Thanks!

swathipil avatar Sep 30 '21 22:09 swathipil

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.

omrodrig avatar Nov 16 '21 17:11 omrodrig

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.

ghost avatar Dec 15 '21 08:12 ghost

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.

ghost avatar Dec 22 '21 10:12 ghost