无法通过Terraform/AZ CLI创建Bing.search.v7服务的解决方案咨询
解决方案:创建Bing Search v7服务的Terraform、AZ CLI及替代方法
Terraform 部署方式
Bing Search v7已从通用认知服务模块中独立,当前AzureRM Terraform Provider提供了专门的azurerm_bing_search_service资源类型,需使用3.0.0及以上版本的provider。示例配置如下:
terraform { required_providers { azurerm = { source = "hashicorp/azurerm" version = ">= 3.0.0" } } } provider "azurerm" { features {} } resource "azurerm_resource_group" "bing_rg" { name = "bing-search-rg" location = "West Europe" } resource "azurerm_bing_search_service" "bing_search" { name = "my-bing-search-v7" location = azurerm_resource_group.bing_rg.location resource_group_name = azurerm_resource_group.bing_rg.name sku_name = "S1" # 可选SKU:S0、S1、S2等 }
执行terraform init(确保provider更新)、terraform plan、terraform apply即可完成创建。
AZ CLI 部署方式
需使用正确的--kind参数指定BingSearchV7,而非通用认知服务的类型。完整命令示例:
az cognitiveservices account create \ --name my-bing-search-v7 \ --resource-group bing-search-rg \ --kind BingSearchV7 \ --sku S1 \ --location westeurope \ --yes
若之前创建失败,大概率是--kind参数错误,或所选区域不支持Bing Search v7(可通过az cognitiveservices account list-skus --location westeurope --kind BingSearchV7确认可用区域和SKU)。
替代方案(若上述方式仍不可行)
ARM模板部署
编写ARM模板指定BingSearchV7类型,示例模板:
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "resources": [ { "type": "Microsoft.CognitiveServices/accounts", "apiVersion": "2023-05-01", "name": "my-bing-search-v7", "location": "West Europe", "sku": { "name": "S1" }, "kind": "BingSearchV7", "properties": {} } ] }
通过AZ CLI部署:
az deployment group create --resource-group bing-search-rg --template-file ./bing-search-template.json
PowerShell 自动化
使用Azure PowerShell模块创建:
New-AzCognitiveServicesAccount -ResourceGroupName "bing-search-rg" -Name "my-bing-search-v7" -Type "BingSearchV7" -SkuName "S1" -Location "WestEurope"
内容的提问来源于stack exchange,提问作者Rajnish Kumar Singh
相关产品推荐
相关产品推荐

