Skip to content

Unable to pass Cost Managment pagination next link url . #39242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arjun-hareendran opened this issue Jan 17, 2025 · 8 comments
Closed

Unable to pass Cost Managment pagination next link url . #39242

arjun-hareendran opened this issue Jan 17, 2025 · 8 comments
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Cost Management - Query All issues in cost management associated with tags, dimensions and forecasts. customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team

Comments

@arjun-hareendran
Copy link

Package Name: azure-mgmt-costmanagement
Package Version: 4.0.1
Operating System: Windows 11 
Python Version: 3.9.12

Requirements.txt

azure-identity
azure-mgmt-resource==20.0.0
azure-mgmt-costmanagement==4.0.1
azure-mgmt-storage==20.0.0
python-dateutil

I am trying to extract some cost details from azure using cost management and since the granularity is at daily, I expect the system to return back couple of thousands of records. What I observed is, the call returns 5000 records, in order to get more records, I referred the documentation and could see the next_link value. I referred the documentation but couldn't find a way to pass this url back to fetch the next set. Is this something the SDK supports?

SUBSCRIPTION_ID = ""

    credential: DefaultAzureCredential = DefaultAzureCredential()
    cost_management_client = CostManagementClient(credential)

    scope = f"/subscriptions/{SUBSCRIPTION_ID}"

    today = datetime.now()
    start_date = datetime(2024, 6, 1)
    end_date = today.replace(
        day=calendar.monthrange(today.year, today.month)[1]
    ).strftime("%Y-%m-%dT23:59:59Z")

    query_definition = QueryDefinition(
        type="AmortizedCost",
        timeframe="Custom",
        time_period=QueryTimePeriod(
            from_property=start_date,
            to=end_date,
        ),
        dataset=QueryDataset(
            granularity="Daily",
            aggregation={
                "TotalCost": QueryAggregation(name="Cost", function="Sum")
            },
            grouping=[
                QueryGrouping(name="ResourceGroup", type="Dimension"),
                QueryGrouping(name="ResourceType", type="Dimension"),
            ],
        ),
    )

    cost_data_response = cost_management_client.query.usage(
        scope=f"/subscriptions/{SUBSCRIPTION_ID}/",
        parameters=query_definition,
    )
    print(len(cost_data_response.rows))
    print(cost_data_response.next_link)
@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jan 17, 2025
@xiangyan99 xiangyan99 added bug This issue requires a change to an existing behavior in the product in order to be resolved. Mgmt This issue is related to a management-plane library. Cost Management - Query All issues in cost management associated with tags, dimensions and forecasts. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Jan 17, 2025
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Jan 17, 2025
@msyyc
Copy link
Member

msyyc commented Jan 20, 2025

@ChenxiJiang333 Please help on this issue.

@ChenxiJiang333
Copy link
Member

got it

@ChenxiJiang333
Copy link
Member

Hi @jayati-tehri, it seems an issue similar with #18927 (comment), is that possible to provide a new operation Query_UsageNextLink in the swagger?

@koetjeengdjalanan
Copy link

Hi, I have a pretty similar use case to @arjun-hareendran, is there any update or work around you guys confident enough to share?

@ChenxiJiang333
Copy link
Member

Hi @jayati-tehri, it seems an issue similar with #18927 (comment), is that possible to provide a new operation Query_UsageNextLink in the swagger?

Hi @msft-vbhatnagar @thramu, could you help take a look at this issue about providing a new operation for the service to make SDK be able to read a nextLink?

@koetjeengdjalanan
Copy link

Hi, has there been any update regarding this issue? or is there a work around yet?

@ChenxiJiang333
Copy link
Member

has opened an issue for service attention: Azure/azure-rest-api-specs#32880. please follow it to get support.

@xiangyan99
Copy link
Member

Please use Azure/azure-rest-api-specs#32880 to track the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Cost Management - Query All issues in cost management associated with tags, dimensions and forecasts. customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team
Projects
None yet
Development

No branches or pull requests

5 participants