1

我将 Azure RM 模板部署与 Visual Studio 2017 资源组项目一起使用,以在 Log Analytics 中部署具有诊断设置的 IoTHub 实例。

单独部署 IoTHub 是成功的,问题在于诊断设置模板的部署。

我正在按照将诊断设置部署为非计算资源模板的说明进行操作

我收到的奇怪错误如下:

错误:代码=无效模板;消息=部署模板验证失败:'69' 行和 '9​​' 列的类型 'providers/diagnosticSettings' 的模板资源 'Microsoft.Insights/BasicDiagnostics' 的段长度不正确。嵌套资源类型必须具有与其资源名称相同的段数。根资源类型的段长度必须比其资源名称大一。

即使我使用提供的示例遵循文档,为什么它会这样失败?

这是我的模板定义:

  "resources": [
    {
      "type": "Microsoft.Devices/IotHubs",
      "sku": {
        "name": "[parameters('sku.name')]",
        "capacity": "[parameters('sku.units')]"
      },
      "name": "[parameters('iothubname')]",
      "apiVersion": "2018-04-01",
      "location": "[resourceGroup().location]",
      "properties": {
        "eventHubEndpoints": {
          "events": {
            "retentionTimeInDays": "[parameters('endpoints.events.retention')]",
            "partitionCount": "[parameters('endpoints.events.partitions')]"
          },
          "operationsMonitoringEvents": {
            "retentionTimeInDays": "[parameters('endpoints.operationsMonitoringEvents.retention')]",
            "partitionCount": "[parameters('endpoints.operationsMonitoringEvents.partitions')]"
          }
        },
        "features": "[parameters('features')]"
      }
    },
    {
      "type": "providers/diagnosticSettings",
      "name": "[concat('Microsoft.Insights/', parameters('iotHub.diagnostics.settingName'))]",
      "dependsOn": [
        "[resourceId('Microsoft.Devices/IoTHubs', parameters('iothubname'))]"
      ],
      "apiVersion": "2017-05-01-preview",
      "properties": {
        "name": "[parameters('iotHub.diagnostics.settingName')]",
        "workspaceId": "[parameters('iotHub.diagnostics.workspaceId')]",
        "logs": [
          {
            "category": "Connections",
            "enabled": true,
            "retentionPolicy": {
              "days": 0,
              "enabled": false
            }
          },
          {
            "category": "Configurations",
            "enabled": true,
            "retentionPolicy": {
              "days": 0,
              "enabled": false
            }
          },
          {
            "category": "D2CTwinOperations",
            "enabled": true,
            "retentionPolicy": {
              "days": 0,
              "enabled": false
            }
          },
          {
            "category": "C2DTwinOperations",
            "enabled": true,
            "retentionPolicy": {
              "days": 0,
              "enabled": false
            }
          }
        ],
        "metrics": [
          {
            "category": "AllMetrics",
            "enabled": true,
            "retentionPolicy": {
              "days": 0,
              "enabled": false
            }
          }
        ]
      }
    }
  ]

非常感谢任何帮助!

4

1 回答 1

1

这需要是 IOT 集线器的子资源,而不是单独的资源。

{
    "type": "Microsoft.Devices/IotHubs",
    "sku": {
        "name": "[parameters('sku.name')]",
        "capacity": "[parameters('sku.units')]"
    },
    "name": "[parameters('iothubname')]",
    "apiVersion": "2018-04-01",
    "location": "[resourceGroup().location]",
    "properties": {
        xxx
    },
    "features": "[parameters('features')]",
    "resources": [
        {
            "type": "providers/diagnosticsSettings",
            xxx
        }
    ]
}

},

于 2018-10-17T07:51:27.613 回答