ARM 模板 - 更新冲突

ARM Template - conflicting update

有用于预配两个 Azure 搜索服务的 ARM 模板

"resources": [
{
  "type": "Microsoft.Search/searchServices",
  "name": "[parameters('serviceName')]",
  "apiVersion": "[parameters('serviceApiVersion')]",
  "location": "[parameters('location')]",
  "properties": {
    "sku": {
      "name": "[parameters('sku')]"
    },
    "replicaCount": 1,
    "partitionCount": 1,
    "hostingMode": "[parameters('hostingMode')]"
  }
},
{
  "type": "Microsoft.Search/searchServices",
  "name": "[concat(parameters('serviceName'), 'secondary')]",
  "apiVersion": "[parameters('serviceApiVersion')]",
  "location": "[parameters('location')]",
  "properties": {
    "sku": {
      "name": "[parameters('sku')]"
    },
    "replicaCount": 1,
    "partitionCount": 1,
    "hostingMode": "[parameters('hostingMode')]"
  }
}]

部署 ARM 模板提供了一项搜索服务,但另一项失败并响应:

{
  "error": {
    "code": "Unknown",
    "message": "There was a conflicting update. No change was made to the resource from this request. RequestId: b65a51b5-cd87-4dc5-82d9-9041ddd1c2dc",
    "target": null,
    "details": null
  }
}

有人遇到这样的问题吗?

可能无法在同一资源组中同时提供搜索服务。尝试将 "dependsOn" 属性 添加到第二个搜索服务。

问题

搜索服务不依赖于其他服务,因此不需要 dependsOn 属性。
我认为问题是你的 arm syntax is invalid.

我不知道您使用的是哪个 apiVersion,但我找不到任何具有相同语法的... (它最像 2015-02-28,但那里不允许 hostingMode 字段)。

解决方案

要么使用不带 hostingmode 的 apiVersion 2015-02-28,要么(如果您需要该字段)使用更新的 apiVersion,其中“sku”位于“属性”之外。以下对我有用!

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
  {
    "type": "Microsoft.Search/searchServices",
    "name": "parameters('serviceName')",
    "apiVersion": "2015-08-19",
    "location": "parameters('location')",
    "properties": {
      "replicaCount": 1,
      "partitionCount": 1,
      "hostingMode": "default"
    },
    "sku": {
      "name": "basic"
    }
  },
  {
    "type": "Microsoft.Search/searchServices",
    "name": "[concat(parameters('serviceName'), 'secondary')]"
    "apiVersion": "2015-08-19",
    "location": "parameters('location')",
    "properties": {
      "replicaCount": 1,
      "partitionCount": 1,
      "hostingMode": "default"
    },
    "sku": {
      "name": "basic"
    }
  }]
}