标准Azure搜索服务的REST API速率限制是多少?

时间:2019-05-09 05:43:48

标签: powershell azure-search

我在Azure DevOps中有一个发布管道,该管道正在最多50个的标准Azure搜索服务上创建36个搜索索引。

我正在使用Powershell脚本来读取存储库中的json文件,以直接使用REST API创建搜索索引。

首先,我删除所有索引,然后再次创建它们。 (以适应存储在存储库中的json文件的任何更改)

在出现以下错误之前,它似乎能够运行约25个REST API调用:

(503) Server Unavailable. You are sending too many requests. Please try again later.

即使我在每个REST API调用之间插入了4秒的延迟(删除或创建索引),我仍然会遇到相同的错误。

我需要做些特别的事情吗?是否在任何地方记录了REST API调用率限制? (我以为here,可惜没有。)

Powershell脚本片段为:($ indexFiles是要应用的json文件的列表)

$headers = @{"Content-Type" = "application/json"
             "api-key" = $SearchAPIKey }

$indexesUrl = "https://$SearchSiteName.search.windows.net/indexes?api-version=$SearchAPIVersion"

Write-Host "Applying the following $($indexFiles.count) index files: "

$indexFiles | ForEach-Object {  $indexData = Get-Content -Path $_.FullName -raw
                                $filename = $_.Name
                                try
                                {
                                    Start-Sleep -Milliseconds $APICallDelay
                                    $response = Invoke-WebRequest -Method Post -Uri $indexesUrl -Headers $headers -Body $indexData
                                    if ($response.StatusCode -eq 201)
                                    {
                                        Write-Host "- $filename applied"
                                    }
                                    else
                                    {
                                        Write-Error "Issues with creating index $filename with Url $indexesUrl. Status code returned was $($response.StatusCode). Msg: $($response.StatusDescription)"
                                    }
                                 }
                                 catch 
                                 {
                                    $summaryMsg = $_.Exception.Message
                                    $detailed = $_.ErrorDetails.Message | ConvertFrom-Json 
                                    $detailedMsg = $detailed.error.message
                                    Write-Error "Error with creating index $filename. $summaryMsg. Detailed error: $detailedMsg"
                                 }
                             }

如果任何人都可以提供任何建议,将不胜感激!

1 个答案:

答案 0 :(得分:0)

已被告知Azure搜索服务的当前限制:

  • 创建索引(POST)每分钟最多可以调用12次
  • 更新索引(PUT)每分钟最多可调用360次
  • 删除索引每分钟最多可调用12次
  • 获取索引每分钟最多可以调用600次
  • 列表索引每分钟最多可调用300次

因此,当前,如果一次要部署12个以上的索引,我们别无选择,只能在代码中放入Start-Sleep -Minutes 2。 :(