快速入门:使用 Azure 资源管理器模板部署 Azure AI 搜索

本文引导你完成在 Azure 门户中使用 Azure 资源管理器 (ARM) 模板部署 Azure AI 搜索资源的过程。

资源管理器模板是定义项目基础结构和配置的 JavaScript 对象表示法 (JSON) 文件。 模板使用声明性语法。 在声明性语法中,你可以在不编写创建部署的编程命令序列的情况下,描述预期部署。

部署中只使用模板中包含的那些属性。 如果需要更多自定义,例如设置网络安全,可以将服务更新为部署后任务。 若要以最少的步骤自定义现有服务,请使用 Azure CLIAzure PowerShell。 如果要评估预览功能,请使用管理 REST API

如果你的环境满足先决条件,而且你熟悉如何使用 ARM 模板,请选择“部署到 Azure”按钮。 Azure 门户中会打开模板。

部署到 Azure

先决条件

如果没有 Azure 订阅,请在开始前创建试用版订阅

查看模板

本快速入门中使用的模板来自 Azure 快速启动模板

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.4.1.14562",
      "templateHash": "5181348332962837883"
    }
  },
  "parameters": {
    "name": {
      "type": "string",
      "maxLength": 60,
      "minLength": 2,
      "metadata": {
        "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."
      }
    },
    "sku": {
      "type": "string",
      "defaultValue": "standard",
      "metadata": {
        "description": "The pricing tier of the search service you want to create (for example, basic or standard)."
      },
      "allowedValues": [
        "free",
        "basic",
        "standard",
        "standard2",
        "standard3",
        "storage_optimized_l1",
        "storage_optimized_l2"
      ]
    },
    "replicaCount": {
      "type": "int",
      "defaultValue": 1,
      "maxValue": 12,
      "minValue": 1,
      "metadata": {
        "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)."
      }
    },
    "partitionCount": {
      "type": "int",
      "defaultValue": 1,
      "allowedValues": [
        1,
        2,
        3,
        4,
        6,
        12
      ],
      "metadata": {
        "description": "Partitions allow for scaling of document count as well as faster indexing by sharding your index over multiple search units."
      }
    },
    "hostingMode": {
      "type": "string",
      "defaultValue": "default",
      "allowedValues": [
        "default",
        "highDensity"
      ],
      "metadata": {
        "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."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "functions": [],
  "resources": [
    {
      "type": "Microsoft.Search/searchServices",
      "apiVersion": "2020-08-01",
      "name": "[parameters('name')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "[parameters('sku')]"
      },
      "properties": {
        "replicaCount": "[parameters('replicaCount')]",
        "partitionCount": "[parameters('partitionCount')]",
        "hostingMode": "[parameters('hostingMode')]"
      }
    }
  ]
}

此模板中定义的 Azure 资源:

部署模板

选择下图登录到 Azure 并打开一个模板。 该模板将创建一个 Azure AI 搜索资源。

部署到 Azure

门户将显示一个窗体,可在其中轻松提供参数值。 某些参数已由模板中的默认值预先填充。 需要提供自己的订阅、资源组、位置和服务名称。 若要在 AI 扩充管道中使用 Azure AI 服务(例如,要分析文本的二进制图像文件),请选择同时提供 Azure AI 搜索和 Azure AI 服务的位置。 对于 AI 扩充工作负载,这两个服务必须位于同一区域。 填写窗体后,需要同意条款和条件,然后选择“购买”按钮以完成部署。

Azure 门户模板显示

查看已部署的资源

部署完成后,可以在门户中访问新的资源组和新的搜索服务。

清理资源

其他 Azure AI 搜索快速入门和教程都是在本快速入门的基础上编写的。 如果你打算继续学习后续快速入门和教程,可能需要保留这些资源。 如果不再需要,可以删除资源组,这会删除 Azure AI 搜索服务和相关资源。

后续步骤

在本快速入门中,你已使用 ARM 模板创建了 Azure AI 搜索服务,并验证了部署。 若要详细了解 Azure AI 搜索和 Azure 资源管理器,请继续阅读以下文章。