为什么此Azure资源管理器模板验证失败?

为什么此Azure资源管理器模板验证失败?,azure,azure-resource-manager,arm-template,Azure,Azure Resource Manager,Arm Template,以下Azure资源管理器模板验证失败,Visual Studio代码表明: 模板验证失败:无效的属性标识符字符:{.Path'resources[6].identity',第311行,位置8 缺少成员名称。arm模板(语法)[311,9] 对象未关闭,应为“}”。arm模板-语法)[319,10] 缺少必需的属性“xmlCfg”arm模板(模式)[51,13] 缺少必需的属性“属性”arm模板(模式)[258,9] 第263行的“identity”属性缺少括号。 正确代码: "apiV

以下Azure资源管理器模板验证失败,Visual Studio代码表明:

  • 模板验证失败:无效的属性标识符字符:{.Path'resources[6].identity',第311行,位置8
  • 缺少成员名称。arm模板(语法)[311,9]
  • 对象未关闭,应为“}”。arm模板-语法)[319,10]
  • 缺少必需的属性“xmlCfg”arm模板(模式)[51,13]
  • 缺少必需的属性“属性”arm模板(模式)[258,9]

  • 第263行的“identity”属性缺少括号。 正确代码:

    "apiVersion": "2017-03-30",
                "type": "Microsoft.Compute/virtualMachines",
                "name": "[variables('vmName')]",
                "location": "[resourceGroup().location]",
                "identity": {
                "type": "SystemAssigned"}, //**Missing bracket**
                "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts/', 
                  variables('storageAccountName'))]",
                "[resourceId('Microsoft.Network/networkInterfaces/', 
                  variables('nicName'))]"
                ],
    

    答案解决了这个问题,但是在将来查找类似错误的最佳实践是什么呢?Visual Studio代码具有验证JSON nad报告此类错误的扩展。您还可以尝试切换到Azure二头肌,它基本上将ARM视为中间语言。
    "apiVersion": "2017-03-30",
                "type": "Microsoft.Compute/virtualMachines",
                "name": "[variables('vmName')]",
                "location": "[resourceGroup().location]",
                "identity": {
                "type": "SystemAssigned"}, //**Missing bracket**
                "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts/', 
                  variables('storageAccountName'))]",
                "[resourceId('Microsoft.Network/networkInterfaces/', 
                  variables('nicName'))]"
                ],