Azure API Throttling

2019-08-06 22:11发布

问题:

I am trying to get a list of all Storage Accounts present in my Azure subscription but I am getting a throttling error.

com.microsoft.azure.CloudException: Status code 429, {"error":{"code":"ResourceCollectionRequestsThrottled","message":"Operation 'Microsoft.Storage/storageAccounts/read' failed as server encountered too many requests. Please try after '17' seconds. Tracking Id is 'e982a894-0f3e-4291-a9b3-e147c18f8f60'."}}

The request prior to this request prints there are 13869 more remaining subscription reads but it still fails.

x-ms-ratelimit-remaining-subscription-reads: 13869

There are around 60 Storage Accounts in my subscription and that according is a small number.

Any idea what's causing this and that too only while listing Storage Accounts and nowhere else.

回答1:

According to this article:

For each subscription and tenant, Resource Manager limits read requests to 15,000 per hour and write requests to 1,200 per hour. These limits apply to each Azure Resource Manager instance; there are multiple instances in every Azure region, and Azure Resource Manager is deployed to all Azure regions. So, in practice, limits are effectively much higher than those listed above, as user requests are generally serviced by many different instances. If your application or script reaches these limits, you need to throttle your requests.

So if you reach the request limit, Resource Manager returns the 429 HTTP status code and a Retry-After value in the header. The Retry-After value specifies the number of seconds your application should wait (or sleep) before sending the next request. If you send a request before the retry value has elapsed, your request is not processed and a new retry value is returned.

I suggest you could use this way to get the number of the read time. If it will meet the limit, you could write codes to limit the application to send the request.