在本快速入门中,使用 Bicep 文件在 Azure 门户中部署 Azure AI 搜索 服务。
Bicep 是一种特定于域的语言 (DSL),使用声明性语法来部署 Azure 资源。 它提供简明的语法、可靠的类型安全性以及对代码重用的支持。 Bicep 会针对你的 Azure 基础结构即代码解决方案提供最佳创作体验。
部署仅使用模板中包含的属性。 如果需要更多自定义,例如 设置网络安全,则可以将服务更新为部署后任务。 若要以最少的步骤自定义现有服务,请使用 Azure CLI 或 Azure PowerShell。 如果要评估预览功能,请使用管理 REST API。
提示
有关使用预配置索引器将Azure AI 搜索部署到 Cosmos DB for NoSQL的替代Bicep模板,请参阅Bicep部署Azure AI 搜索。 目前没有用于 Azure AI 搜索 数据平面操作(例如创建索引)的 Bicep 模板支持,不过你可以添加一个调用 REST API 的模块。 此示例包含一个模块,用于创建索引、数据源连接器和以 5 分钟的间隔从 Cosmos DB 刷新的索引器。
先决条件
如果没有 Azure 订阅,请在开始前创建一个试用版订阅。
查阅 Bicep 文件
本快速入门中使用的 Bicep 文件来自 Azure 快速入门模板。
@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资源:
- Microsoft.Search/searchServices:创建 Azure AI 搜索服务
部署 Bicep 文件
将 Bicep 文件在本地计算机上另存为 main.bicep。
使用 Azure CLI 或 Azure PowerShell 部署 Bicep 文件。
az group create --name exampleRG --location chinaeast2 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 资源管理器,请参阅以下文章: