Azure 如果出现http错误,az cli命令能否自动重试429
我注意到,az命令仅在向其传递--debug标志时才打印http头。 例如 标题打印到stderr,stdout不包含任何内容 在HTTP 429的情况下,错误太多,建议在响应头retry after中提到的间隔之后重试 是否有任何机制可以使az cli在出现HTTP 429错误时自动重试API 编辑——内置于az命令中的重试Azure 如果出现http错误,az cli命令能否自动重试429,azure,http-headers,azure-cli,throttling,Azure,Http Headers,Azure Cli,Throttling,我注意到,az命令仅在向其传递--debug标志时才打印http头。 例如 标题打印到stderr,stdout不包含任何内容 在HTTP 429的情况下,错误太多,建议在响应头retry after中提到的间隔之后重试 是否有任何机制可以使az cli在出现HTTP 429错误时自动重试API 编辑——内置于az命令中的重试 urllib3.util.retry : Incremented Retry for (url='/subscriptions/REMOVED/providers/Mic
urllib3.util.retry : Incremented Retry for (url='/subscriptions/REMOVED/providers/Microsoft.Storage/storageAccounts?api-version=2019-06-01'): Retry(total=3, connect=4, read=4, redirect=None, status=None)
urllib3.util.retry : Incremented Retry for (url='/subscriptions/REMOVED/providers/Microsoft.Storage/storageAccounts?api-version=2019-06-01'): Retry(total=2, connect=4, read=4, redirect=None, status=None)
urllib3.util.retry : Incremented Retry for (url='/subscriptions/REMOVED/providers/Microsoft.Storage/storageAccounts?api-version=2019-06-01'): Retry(total=1, connect=4, read=4, redirect=None, status=None)
urllib3.util.retry : Incremented Retry for (url='/subscriptions/REMOVED/providers/Microsoft.Storage/storageAccounts?api-version=2019-06-01'): Retry(total=0, connect=4, read=4, redirect=None, status=None)
根据到目前为止收到的响应,答案是“否”,调用者必须使用--debug选项运行az命令并解析stderr。下面是示例Groovy代码
def pat = /'Retry-After': '(\d+)'/
stderr.split("\n").each { line ->
def m = line =~ pat
if (m.size() > 0 && m.hasGroup()) {
retryAfterDuration = Integer.parseInt(m[0][1])
println("Found Retry-After header, value = ${retryAfterDuration}")
}
}
下面是示例响应
msrest.http_logger : Response status: 429
msrest.http_logger : Response headers:
msrest.http_logger : 'Cache-Control': 'no-cache'
msrest.http_logger : 'Pragma': 'no-cache'
msrest.http_logger : 'Content-Length': '207'
msrest.http_logger : 'Content-Type': 'application/json'
msrest.http_logger : 'Expires': '-1'
msrest.http_logger : 'Retry-After': '17'
msrest.http_logger : 'x-ms-request-id': 'c7102dca-4bb1-4d24-8333-0128b8b85b24'
msrest.http_logger : 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
msrest.http_logger : 'Server': 'Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0'
msrest.http_logger : 'x-ms-ratelimit-remaining-subscription-reads': '11989'
msrest.http_logger : 'x-ms-correlation-request-id': '3a7ba2e1-6908-414b-b162-d6f41dc10521'
msrest.http_logger : 'x-ms-routing-request-id': 'EASTUS:20200830T234133Z:3a7ba2e1-6908-414b-b162-d6f41dc10521'
msrest.http_logger : 'X-Content-Type-Options': 'nosniff'
msrest.http_logger : 'Date': 'Sun, 30 Aug 2020 23:41:32 GMT'
msrest.http_logger : 'Connection': 'close'
msrest.http_logger : Response content:
msrest.http_logger : {"error":{"code":"TooManyRequests","message":"The request is being throttled as the limit has been reached for operation type - List_PerHour. For more information, see - https://aka.ms/srpthrottlinglimits"}}
msrest.exceptions : The request is being throttled as the limit has been reached for operation type - List_PerHour. For more information, see - https://aka.ms/srpthrottlinglimits
为什么不
而(!success&&retryCount
?我认为没有,但我没有任何证据支持它up@ShridharRKulkarni如果每个打电话的人都不必这样做,那就太好了。而且,只使用--debug选项打印标题,该选项打印大量信息,调用方必须解析stderr,查找429,解析一个又一个标题,然后重试。我明白你的意思。据我所知,正如另一位用户所说,对于您所要求的内容,没有这样的内置功能。如果您尝试为自己开发一个,您可以从查看stderr中获得灵感,az命令通过urllib3重试选项进行4次重试。(更新原文)。因此,通常需要0.8秒的命令在大约60秒后完成,因此重试之间的延迟似乎是指数级的,但它仍然无法防止429个错误,因为它不查看头后重试。
msrest.http_logger : Response status: 429
msrest.http_logger : Response headers:
msrest.http_logger : 'Cache-Control': 'no-cache'
msrest.http_logger : 'Pragma': 'no-cache'
msrest.http_logger : 'Content-Length': '207'
msrest.http_logger : 'Content-Type': 'application/json'
msrest.http_logger : 'Expires': '-1'
msrest.http_logger : 'Retry-After': '17'
msrest.http_logger : 'x-ms-request-id': 'c7102dca-4bb1-4d24-8333-0128b8b85b24'
msrest.http_logger : 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
msrest.http_logger : 'Server': 'Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0'
msrest.http_logger : 'x-ms-ratelimit-remaining-subscription-reads': '11989'
msrest.http_logger : 'x-ms-correlation-request-id': '3a7ba2e1-6908-414b-b162-d6f41dc10521'
msrest.http_logger : 'x-ms-routing-request-id': 'EASTUS:20200830T234133Z:3a7ba2e1-6908-414b-b162-d6f41dc10521'
msrest.http_logger : 'X-Content-Type-Options': 'nosniff'
msrest.http_logger : 'Date': 'Sun, 30 Aug 2020 23:41:32 GMT'
msrest.http_logger : 'Connection': 'close'
msrest.http_logger : Response content:
msrest.http_logger : {"error":{"code":"TooManyRequests","message":"The request is being throttled as the limit has been reached for operation type - List_PerHour. For more information, see - https://aka.ms/srpthrottlinglimits"}}
msrest.exceptions : The request is being throttled as the limit has been reached for operation type - List_PerHour. For more information, see - https://aka.ms/srpthrottlinglimits