CostManagement Query operation - too many request only after 4 request

Stanislav Fotev 100 Reputation points
2024-01-11T10:50:32.0866667+00:00

Hi, I am invoking the Query operation of the CostManagement API. But only after 4 consecutive request I am getting a throttling errors:

{
    "error": {
        "code": "429",
        "message": "Too many requests. Please retry."
    }
}


The thins is, that if I use a token from the web portal I have no such restriction, but one generated from the Java SDK is only allowed 4 consecutive calls.

Is this the expected behavior or is there a way to generate no restriction token trough the Java SDK?

Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
2,697 questions
{count} votes

Accepted answer
  1. Monalla-MSFT 13,031 Reputation points
    2024-01-11T17:23:13.2033333+00:00

    Stanislav Fotev - Welcome to Microsoft Q&A and thanks for reaching out to us.

    Yes, we have a stringent throttling limit on this API. The recommended pattern to get cost data is using API or exports https://learn.microsoft.com/en-us/azure/cost-management-billing/automate/get-small-usage-datasets-on-demand and build queries on top of that.

    When you generate a token through the Azure portal, it may have different rate limits than a token generated through the Java SDK. This is because the portal may have different usage patterns and requirements than a Java application.

    To avoid hitting the rate limits, you can try implementing a backoff strategy in your Java application. This means that if you receive a 429 error, you wait for a certain amount of time before retrying the request. The amount of time you wait can increase with each consecutive error to avoid overwhelming the service.

    Hope this helps. and please feel free to reach out if you have any further questions.


    If the above response was helpful, please feel free to "Accept as Answer" and click "Yes" so it can be beneficial to the community.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.