快速入門:使用 Bicep 部署 Azure AI 搜尋服務

注意

Azure AI 搜尋服務 可透過 Azure 入口網站、REST API 及 Azure SDK 取得。 它同時也是 Foundry IQ 的基礎,這是一個管理式知識層,能將企業內容轉化為可重複使用、權限感知的知識庫,供 Microsoft Foundry 入口網站中的代理使用。

在這個快速入門中,請使用 Bicep 檔案在 Azure 入口網站部署 Azure AI 搜尋服務 服務。

Bicep 是使用宣告式語法來部署 Azure 資源的特定領域語言 (DSL)。 其提供簡潔的語法、可靠的類型安全,並支援程式碼重複使用。 Bicep 能夠為您在 Azure 中的基礎結構即程式碼解決方案,提供最佳的製作體驗。

部署僅使用範本中包含的屬性。 如果你需要更多客製化,例如 設定網路安全,可以在部署後更新服務。 若要使用最少的步驟自訂現有服務,請使用 Azure CLI 或 Azure PowerShell。 如果您正在評估預覽功能,請使用管理 REST API。

提示

若想了解一個能將Azure AI 搜尋服務部署到Cosmos DB for NoSQL的替代Bicep範本,請參見Azure AI 搜尋服務部署Bicep。 Bicep 沒有支援 Azure AI 搜尋服務 資料平面的範本操作,例如建立索引,但你可以新增一個模組來呼叫 REST API。 此範例包含一個模組,建立索引、資料來源連接器及每 5 分鐘從 Cosmos DB 更新的索引器。

必要條件

如果您沒有 Azure 訂用帳戶,請在開始前建立免費帳戶。

檢閱 Bicep 檔案

這個快速入門指南使用 Azure 快速入門範本中的 Bicep 檔案。

@description('Service name must only contain lowercase letters, digits or dashes, cannot use dash as the first two or last one characters, cannot contain consecutive dashes, and is limited between 2 and 60 characters in length.')
@minLength(2)
@maxLength(60)
param name string

@allowed([
  'free'
  'basic'
  'standard'
  'standard2'
  'standard3'
  'storage_optimized_l1'
  'storage_optimized_l2'
])
@description('The pricing tier of the search service you want to create (for example, basic or standard).')
param sku string = 'standard'

@description('Replicas distribute search workloads across the service. You need at least two replicas to support high availability of query workloads (not applicable to the free tier).')
@minValue(1)
@maxValue(12)
param replicaCount int = 1

@description('Partitions allow for scaling of document count as well as faster indexing by sharding your index over multiple search units.')
@allowed([
  1
  2
  3
  4
  6
  12
])
param partitionCount int = 1

@description('Applicable only for SKUs set to standard3. You can set this property to enable a single, high density partition that allows up to 1000 indexes, which is much higher than the maximum indexes allowed for any other SKU.')
@allowed([
  'default'
  'highDensity'
])
param hostingMode string = 'default'

@description('Location for all resources.')
param location string = resourceGroup().location

resource search 'Microsoft.Search/searchServices@2020-08-01' = {
  name: name
  location: location
  sku: {
    name: sku
  }
  properties: {
    replicaCount: replicaCount
    partitionCount: partitionCount
    hostingMode: hostingMode
  }
}

Bicep 檔案定義了以下 Azure 資源:

部署 Bicep 檔案

  1. 將 Bicep 檔案儲存為 本機電腦上的 main.bicep 。

  2. 使用 Azure CLI 或 Azure PowerShell 部署 Bicep 檔案。

    az group create --name exampleRG --location eastus
    az deployment group create --resource-group exampleRG --template-file main.bicep --parameters serviceName=<service-name>
    

    注意

    以搜尋服務名稱取代 <service-name>。 此服務名稱必須僅包含小寫字母、數字或連字號。 您不能將破折號作為前兩個字元或最後一個字元。 此名稱長度下限為 2 個字元,最大長度為 60 個字元。

    當部署完成時,您會看到指出部署成功的訊息。

檢閱已部署的資源

使用 Azure 入口網站、Azure CLI 或 Azure PowerShell 來列出資源群組中已部署的資源。

az resource list --resource-group exampleRG

清除資源

Azure AI 搜尋服務是可計費的資源。 如果你不再需要,請從訂閱中刪除它以避免費用。 您可以使用 Azure 入口網站、Azure CLI 或 Azure PowerShell 來刪除資源群組及其資源。

az group delete --name exampleRG

在本快速入門中,您使用 Bicep 檔案建立 Azure AI 搜尋服務,然後驗證部署。 若要深入瞭解 Azure AI 搜尋服務和 Azure Resource Manager,請參閱下列文章: