This is the error I’m getting after attempting for 6 times with an interval of 10 seconds.
Failed with StatusCode: TooManyRequests RequestMessage: Method: PUT, RequestUri: 'https://management.azure.com/subscriptions/aaa-bbb-ccc-ddd/resourceGroups/reqource_grp/providers/Microsoft.Compute/virtualMachines/VM_NAME?api-version=2022-03-01', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
Accept: application/json
Authorization: Bearer ""
traceparent: 00-14a9ce9cba751f4cfb217ec0b8991ede-b1b327a3be820f60-00
Content-Type: application/json; charset=utf-8
Content-Length: 1494
}
Content: System.Net.Http.HttpConnectionResponseContent
ReasonPhrase:
Headers Cache-Control: no-cache
Pragma: no-cache
Retry-After: 10
x-ms-failure-cause: gateway
x-ms-request-id: 345672-331f-4c6a-becc-3f98a9459a5c
x-ms-correlation-request-id: 34563cf-331f-4c6a-becc-3f98a9459a5c
x-ms-routing-request-id: 20240719T104204Z:675a93cf-331f-4c6a-becc-3f98a9459a5c
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Cache: CONFIG_NOCACHE
X-MSEdge-Ref: Ref A: 316D2AEF72A1434BBFA503FB3AFC2936 Ref B: AMS231032609023 Ref C: 2024-07-19T10:42:04Z
Date: Fri, 19 Jul 2024 10:42:03 GMT
Please refer the policy code mentioned below:-
TimeSpan timeBetweenRetryForRequestUnitLimit = TimeSpan.FromSeconds(10); int maxAttemptsToRetry = 6;
Policy.HandleResult<HttpResponseMessage>(response => !response.IsSuccessStatusCode)
.WaitAndRetryAsync(maxAttemptsToRetry, retryAttempt => {
log.LogInformation("Success Code Failure Attempt: {retryCount} n Payload: {text}", retryAttempt, text);
return timeBetweenRetryForRequestUnitLimit;});
Also in the response I can’t see the header x-ms-ratelimit-remaining-subscription-writes
https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/request-limits-and-throttling
3
When you get a 429 retry response, there is a field that tells you how long to wait before trying again.
From your response:
Retry-After: 10
That’s how long you have to wait. Your 10 seconds may or may not be enough, and if it’s not, it’ll immediately get rejected.
That Retry-After
is in seconds.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
1