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

Why does this Azure Resource Manager Template fail validation?

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

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

    {
        "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "virtualNetworkName": {
                "type": "String",
                "defaultValue": "webapp101-vnet"
            },
            "virtualMachineName": {
                "type": "String",
                "defaultValue": "webapp101-vm01"
            },
            "virtualMachineSize": {
                "type": "String",
                "defaultValue": "Standard_DS1_v2"
            },
            "adminUsername": {
                "type": "String",
                "defaultValue": "azureuser"
            },
            "adminPassword": {
                "type": "SecureString"
            }
        },
        "variables": {
            "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'sawinvm')]",
            "accountid": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
            "vmName": "[parameters('virtualMachineName')]",
            "networkSecurityGroupName": "[concat(parameters('virtualNetworkName'), '-nsg')]",
            "addressPrefix": "10.1.0.0/16",
            "subnetPrefix": "10.1.0.0/24",
            "subnetName": "web",
            "publicIPAddressName": "[concat(variables('vmName'), '-ip')]",
            "nicName": "[concat(variables('vmName'), '-nic')]",
            "subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworkName'), variables('subnetName'))]"
        },
        "resources": [
            {
                "type": "Microsoft.Compute/virtualMachines/extensions",
                "name": "[concat(variables('vmName'), '/', 'Microsoft.Insights.VMDiagnosticsSettings')]",
                "apiVersion": "2017-12-01",
                "location": "[resourceGroup().location]",
                "dependsOn": [
                "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
                ],
                "properties": {
                "publisher": "Microsoft.Azure.Diagnostics",
                "type": "IaaSDiagnostics",
                "typeHandlerVersion": "1.12",
                "autoUpgradeMinorVersion": true,
                "settings": {
                    "WadCfg": {
                    "DiagnosticMonitorConfiguration": {
        "overallQuotaInMB": 4096,
        "DiagnosticInfrastructureLogs": {
                        "scheduledTransferLogLevelFilter": "Error"
            },
                        "Directories": {
                        "scheduledTransferPeriod": "PT1M",
        "IISLogs": {
                            "containerName": "wad-iis-logfiles"
                        },
                        "FailedRequestLogs": {
                            "containerName": "wad-failedrequestlogs"
                        }
                        },
                        "PerformanceCounters": {
                        "scheduledTransferPeriod": "PT1M",
                        "sinks": "AzMonSink",
                        "PerformanceCounterConfiguration": [
                            {
                            "counterSpecifier": "\Memory\Available Bytes",
                            "sampleRate": "PT15S"
                            },
                            {
                            "counterSpecifier": "\Memory\% Committed Bytes In Use",
                            "sampleRate": "PT15S"
                            },
                            {
                            "counterSpecifier": "\Memory\Committed Bytes",
                            "sampleRate": "PT15S"
                            }
                        ]
                        },
                        "WindowsEventLog": {
                        "scheduledTransferPeriod": "PT1M",
                        "DataSource": [
                            {
                            "name": "Application!*"
                            }
                        ]
                        },
                        "Logs": {
                        "scheduledTransferPeriod": "PT1M",
                        "scheduledTransferLogLevelFilter": "Error"
                        }
                    },
                    "SinksConfig": {
                        "Sink": [
                        {
                            "name" : "AzMonSink",
                            "AzureMonitor" : {}
                        }
                        ]
                    }
                    },
                    "StorageAccount": "[variables('storageAccountName')]"
                },
                "protectedSettings": {
                    "storageAccountName": "[variables('storageAccountName')]",
                    "storageAccountKey": "[listKeys(variables('accountid'),'2015-06-15').key1]",
                    "storageAccountEndPoint": "https://core.windows.net/"
                }
                }
            },
            {
            "type": "Microsoft.Compute/virtualMachines/extensions",
            "name": "[concat(variables('vmName'), '/', 'WADExtensionSetup')]",
            "apiVersion": "2017-12-01",
            "location": "[resourceGroup().location]",
            "dependsOn": [
                "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]" ],
            "properties": {
                "publisher": "Microsoft.ManagedIdentity",
                "type": "ManagedIdentityExtensionForWindows",
                "typeHandlerVersion": "1.0",
                "autoUpgradeMinorVersion": true,
                "settings": {
                    "port": 50342
                }
            }
        },
            {
                "type": "Microsoft.Storage/storageAccounts",
                "name": "[variables('storageAccountName')]",
                "apiVersion": "2018-07-01",
                "location": "[resourceGroup().location]",
                "sku": {
                    "name": "Standard_LRS",
                    "tier": "Standard"
                },
                "kind": "StorageV2",
                "properties": {
                    "networkAcls": {
                        "bypass": "AzureServices",
                        "virtualNetworkRules": [],
                        "ipRules": [],
                        "defaultAction": "Allow"
                    },
                    "supportsHttpsTrafficOnly": false,
                    "encryption": {
                        "services": {
                            "file": {
                                "enabled": true
                            },
                            "blob": {
                                "enabled": true
                            }
                        },
                        "keySource": "Microsoft.Storage"
                    }
                },
                "dependsOn": []
            },
            {
                "type": "Microsoft.Network/networkSecurityGroups",
                "name": "[variables('networkSecurityGroupName')]",
                "apiVersion": "2018-08-01",
                "location": "[resourceGroup().location]",
                "tags": {},
                "properties": {
                    "securityRules": [
                        {
                            "name": "HTTP",
                            "properties": {
                                "priority": 300,
                                "protocol": "TCP",
                                "access": "Allow",
                                "direction": "Inbound",
                                "sourceAddressPrefix": "*",
                                "sourcePortRange": "*",
                                "destinationAddressPrefix": "*",
                                "destinationPortRange": "80"
                            }
                        },
                        {
                            "name": "RDP",
                            "properties": {
                                "priority": 320,
                                "protocol": "TCP",
                                "access": "Allow",
                                "direction": "Inbound",
                                "sourceAddressPrefix": "*",
                                "sourcePortRange": "*",
                                "destinationAddressPrefix": "*",
                                "destinationPortRange": "3389"
                            }
                        }
                    ]
                },
                "dependsOn": []
            },
            {
                "type": "Microsoft.Network/virtualNetworks",
                "name": "[parameters('virtualNetworkName')]",
                "apiVersion": "2018-08-01",
                "location": "[resourceGroup().location]",
                "tags": {},
                "properties": {
                    "addressSpace": {
                        "addressPrefixes": [
                            "[variables('addressPrefix')]"
                        ]
                    },
                    "subnets": [
                        {
                            "name": "[variables('subnetName')]",
                            "properties": {
                                "addressPrefix": "[variables('subnetPrefix')]",
                                "networkSecurityGroup": {
                                    "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
                                }
                            }
                        }
                    ]
                },
                "dependsOn": [
                    "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
                ]
            },
            {
                "type": "Microsoft.Network/networkInterfaces",
                "name": "[variables('nicName')]",
                "apiVersion": "2018-04-01",
                "location": "[resourceGroup().location]",
                "dependsOn": [
                    "[concat('Microsoft.Network/networkSecurityGroups/', variables('networkSecurityGroupName'))]",
                    "[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
                    "[concat('Microsoft.Network/publicIpAddresses/', variables('publicIpAddressName'))]"
                ],
                "properties": {
                    "ipConfigurations": [
                        {
                            "name": "ipconfig1",
                            "properties": {
                                "privateIPAllocationMethod": "Dynamic",
                                "publicIpAddress": {
                                    "id": "[resourceId('Microsoft.Network/publicIpAddresses', variables('publicIpAddressName'))]"
                                },
                                "subnet": {
                                    "id": "[variables('subnetRef')]"
                                }
                            }
                        }
                    ]
                }
            },
            {
                "apiVersion": "2017-03-30",
                "type": "Microsoft.Compute/virtualMachines",
                "name": "[variables('vmName')]",
                "location": "[resourceGroup().location]",
                "identity": {
                "type": "SystemAssigned",
                "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
                "[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
                ],
                "properties": {
                    "hardwareProfile": {
                        "vmSize": "[parameters('virtualMachineSize')]"
                    },
                    "storageProfile": {
                        "osDisk": {
                            "createOption": "fromImage",
                            "managedDisk": {
                                "storageAccountType": null
                            }
                        },
                        "imageReference": {
                            "publisher": "MicrosoftWindowsServer",
                            "offer": "WindowsServer",
                            "sku": "2019-Datacenter",
                            "version": "latest"
                        }
                    },
                    "osProfile": {
                        "computerName": "[variables('vmName')]",
                        "adminUsername": "[parameters('adminUsername')]",
                        "adminPassword": "[parameters('adminPassword')]",
                        "windowsConfiguration": {
                            "enableAutomaticUpdates": true,
                            "provisionVmAgent": true
                        }
                    },
                    "networkProfile": {
                        "networkInterfaces": [
                            {
                                "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
                            }
                        ]
                    },
                    "diagnosticsProfile": {
                        "bootDiagnostics": {
                            "enabled": true,
                            "storageUri": "[reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob]"
                        }
                    }
                }
            },
            {      
                "name": "[variables('publicIpAddressName')]",
                "type": "Microsoft.Network/publicIpAddresses",            
                "apiVersion": "2019-04-01",
                "location": "[resourceGroup().location]",
                "properties": {
                    "publicIpAllocationMethod": null
                }
            }
        ]
    }

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

"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'))]"
            ],