2017-11-20 8 views
1

저는 정자가 기계를 던질 때 필요할 때마다 기본 json을 만들려고했습니다. 나는 그것의 대부분은 그러나 나는 다음과 같은 오류가 점점 오전 완료 가지고 :JSON 예기치 않은 문자 시퀀스를 만드는 중 오류가 발생했습니다.

Line 158 Unexpected character sequence in member name 
Line 167 A member with the name 'Properties' already exists 

내가 고유 67 개의 요구를 이해하지만 매번 내가 변경하고이 {더 오류를 생성 제거합니다.

예상치 못한 문자는 {157 행에있는 것입니다.

내 템플릿은 다음과 같습니다.

{ 
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 
    "contentVersion": "1.0.0.0", 
    "parameters": { 
    "location": { 
     "type": "string" 
    }, 
    "virtualMachineName": { 
     "type": "string" 
    }, 
    "offer": { 
     "type": "string", 
     "defaultvalue": "Windows", 
     "allowedValues": [ 
     "windows", 
     "centos", 
     "RHEL" 
     ] 
    }, 
    "sku": { 
     "type": "string", 
     "defaultvalue": "2012-r2-datacenter", 
     "allowedValues": [ 
     "2012-R2-Datacenter", 
     "2012-R2", 
     "68", 
     "72", 
     "73", 
     "74" 
     ] 
    }, 
    "virtualMachineSize": { 
     "type": "string", 
     "defaultvalue": "standard_A0", 
     "allowedValues": [ 
     "Standard_A0", 
     "Standard_A1", 
     "standard_A2" 
     ] 
    }, 
    "adminUsername": { 
     "type": "string" 
    }, 
    "ipaddress": { 
     "type": "string" 
    }, 
    "virtualNetworkName": { 
     "type": "string" 
    }, 
    "networkInterfaceName": { 
     "type": "string" 
    }, 
    "networkSecurityGroupName": { 
     "type": "string" 
    }, 
    "adminPassword": { 
     "type": "securestring" 
    }, 
    "storageAccountName": { 
     "type": "string" 
    }, 
    "diagnosticsStorageAccountName": { 
     "type": "string" 
    }, 
    "diagnosticsStorageAccountId": { 
     "type": "string" 
    }, 
    "subnetName": { 
     "type": "string" 
    }, 
    "ContainerName": { 
     "type": "string" 
    }, 
    "autoShutdownStatus": { 
     "type": "string" 
    }, 
    "autoShutdownTime": { 
     "type": "string" 
    }, 
    "autoShutdownTimeZone": { 
     "type": "string" 
    }, 
    "autoShutdownNotificationStatus": { 
     "type": "string" 
    } 
    }, 
    "variables": { 
    "vnetId": "[resourceId('avset','Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]", 
    "subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]", 
    "stdvhdcontainername": "[concat(parameters('Containername'))]", 
    "vmosidiskname": "[concat(parameters('virtualMachineName'),'-osdisk')]" 
    }, 
    "resources": [ 
    { 
     "name": "[parameters('virtualMachineName')]", 
     "type": "Microsoft.Compute/virtualMachines", 
     "apiVersion": "2016-04-30-preview", 
     "location": "[parameters('location')]", 
     "dependsOn": [ 
     "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]" 
     ], 
     "properties": { 
     "diagnosticsProfile": { 
      "bootDiagnostics": { 
      "enabled": true, 
      "storageUri": "[concat (parameters('diagnosticsStorageAccountName')), ['blob']]" 
      } 
     }, 
     "hardwareProfile": { 
      "vmSize": "[parameters('virtualMachineSize')]" 
     }, 
     "networkProfile": { 
      "networkInterfaces": [ 
      { 
       "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]" 
      } 
      ] 
     }, 
     "osProfile": { 
      "computerName": "[parameters('virtualMachineName')]", 
      "adminUsername": "[parameters('adminUsername')]", 
      "adminPassword": "[parameters('adminPassword')]" 
     }, 
     "storageProfile": { 
      "imageReference": { 
      "offer": "[concat(parameters('offer'))]", 
      "sku": "[concat(parameters('offer'))]", 
      "version": "latest" 
      } 
     }, 
     "osDisk": { 
      "vhd": { 
      "name": "[variables('vmosidiskname')]", 
      "uri": "[concat('http://', parameters('storageAccountName'), '.blob.core.windows.net/', variables('stdvhdcontainername'),'/', variables('vmosidiskname'), '.vhd')]" 
      }, 
      "name": "[parameters('virtualMachineName')]" 
     }, 
     "name": "[concat('shutdown-computevm-', parameters('virtualMachineName'))]", 
     "type": "Microsoft.DevTestLab/schedules", 
     "apiVersion": "2017-04-26-preview", 
     "location": "[parameters('location')]", 
     "properties": { 
      "status": "[parameters('autoShutdownStatus')]", 
      "taskType": "ComputeVmShutdownTask", 
      "dailyRecurrence": { 
      "time": "[parameters('autoShutdownTime')]" 
      }, 
      "timeZoneId": "[parameters('autoShutdownTimeZone')]", 
      "targetResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]", 
      "notificationSettings": { 
      "status": "[parameters('autoShutdownNotificationStatus')]", 
      "timeInMinutes": "30" 
      }, 
      "dependsOn": [ 
      "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]" 
      ] 
     }, 
     { 
      "name": "[parameters('networkInterfaceName')]", 
      "type": "Microsoft.Network/networkInterfaces", 
      "apiVersion": "2016-09-01", 
      "location": "[parameters('location')]" 
     }, 
     "dependsOn": [ 
      "[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]" 
     ], 
     "properties": { 
      "ipConfigurations": [ 
      { 
       "name": "ipconfig1", 
       "properties": { 
       "subnet": { 
        "id": "[variables('subnetRef')]" 
       }, 
       "privateipaddress": "[concat(parameters('ipaddress'))]", 
       "privateIPAllocationMethod": "static" 
       } 
      } 
      ] 
     } 

     }, 
     "outputs": [ 
     { 
      "adminUsername": { 
      "type": "string", 
      "value": "[parameters('adminUsername')]" 
      } 

     } 
     ] 
    } 
    ] 
} 


Any pointers would be greatly appreciated.. thanks for your help :) 

에 Params는 다음과 같습니다 :

{ 
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", 
    "contentVersion": "1.0.0.0", 
    "parameters": { 
    "location": { 
     "value": "westeurope" 
    }, 
    "virtualMachineName": { 
     "value": "cent-os-vm2" 
    }, 
    "virtualMachineSize": { 
     "value": "Standard_A0" 
    }, 
    "adminUsername": { 
     "value": "localadmin" 
    }, 
    "virtualNetworkName": { 
     "value": "avset-vnet" 
    }, 
    "networkInterfaceName": { 
     "value": "cent-os-vm01652" 
    }, 
    "networkSecurityGroupName": { 
     "value": "cent-os-vm01-nsg" 
    }, 
    "storageAccountName": { 
     "value": "avsetdisks419" 
    }, 
    "diagnosticsStorageAccountName": { 
     "value": "avsetdiag112" 
    }, 
    "diagnosticsStorageAccountId": { 
     "value": "avsetdiag117" 
    }, 
    "subnetName": { 
     "value": "default" 
    }, 
    "autoShutdownStatus": { 
     "value": "Enabled" 
    }, 
    "autoShutdownTime": { 
     "value": "19:00" 
    }, 
    "autoShutdownTimeZone": { 
     "value": "UTC" 
    }, 
    "autoShutdownNotificationStatus": { 
     "value": "Disabled" 
    }, 
    "ContainerName": { 
     "value": "vhd" 
    }, 
    "offer": { 
     "value": "windows" 
    }, 
    "sku": { 
     "value": "2012-R2-Datacenter" 
    }, 
    "ipaddress": { 
     "value": "10.0.1.9" 
    } 
    } 
} 
+0

https://jsonlint.com/은 JSON 템플릿의 유효성을 검사하는 훌륭한 리소스입니다. – M0rty

+0

안녕하세요, 귀하의 도움을위한 thaks, 나는 매개 변수를 추가했습니다 : –

+0

@ NorrinRad 가능하다면, 당신은 내게 당신의 로그를 보여줄 수 있습니까? –

답변

1

이 템플릿에서 많은 실수가있다. 다음 템플릿이 작동해야합니다.

{ 
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 
    "contentVersion": "1.0.0.0", 
    "parameters": { 
    "location": { 
     "type": "string" 
    }, 
    "virtualMachineName": { 
     "type": "string" 
    }, 
    "offer": { 
     "type": "string", 
     "defaultvalue": "windows", 
     "allowedValues": [ 
     "windows", 
     "centos", 
     "RHEL" 
     ] 
    }, 
    "sku": { 
     "type": "string", 
     "defaultvalue": "2012-R2-Datacenter", 
     "allowedValues": [ 
     "2012-R2-Datacenter", 
     "2012-R2", 
     "68", 
     "72", 
     "73", 
     "74" 
     ] 
    }, 
    "virtualMachineSize": { 
     "type": "string", 
     "defaultvalue": "Standard_A0", 
     "allowedValues": [ 
     "Standard_A0", 
     "Standard_A1", 
     "standard_A2" 
     ] 
    }, 
    "adminUsername": { 
     "type": "string" 
    }, 
    "ipaddress": { 
     "type": "string" 
    }, 
    "virtualNetworkName": { 
     "type": "string" 
    }, 
    "networkInterfaceName": { 
     "type": "string" 
    }, 
    "networkSecurityGroupName": { 
     "type": "string" 
    }, 
    "adminPassword": { 
     "type": "securestring" 
    }, 
    "storageAccountName": { 
     "type": "string" 
    }, 
    "diagnosticsStorageAccountName": { 
     "type": "string" 
    }, 
    "diagnosticsStorageAccountId": { 
     "type": "string" 
    }, 
    "subnetName": { 
     "type": "string" 
    }, 
    "ContainerName": { 
     "type": "string" 
    }, 
    "autoShutdownStatus": { 
     "type": "string" 
    }, 
    "autoShutdownTime": { 
     "type": "string" 
    }, 
    "autoShutdownTimeZone": { 
     "type": "string" 
    }, 
    "autoShutdownNotificationStatus": { 
     "type": "string" 
    } 
    }, 
    "variables": { 
    "vnetId": "[resourceId('avset','Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]", 
    "subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]", 
    "stdvhdcontainername": "[concat(parameters('Containername'))]", 
    "vmosidiskname": "[concat(parameters('virtualMachineName'),'-osdisk')]" 
    }, 
    "resources": [ 
    { 
     "name": "[parameters('virtualMachineName')]", 
     "type": "Microsoft.Compute/virtualMachines", 
     "apiVersion": "2016-04-30-preview", 
     "location": "[parameters('location')]", 
     "dependsOn": [ 
     "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]" 
     ], 
     "properties": { 
      "diagnosticsProfile": { 
      "bootDiagnostics": { 
       "enabled": true, 
       "storageUri": "[concat (parameters('diagnosticsStorageAccountName')), ['blob']]" 
      } 
      }, 
      "hardwareProfile": { 
      "vmSize": "[parameters('virtualMachineSize')]" 
      }, 
      "networkProfile": { 
       "networkInterfaces": [ 
       { 
       "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]" 
       } 
      ] 
      }, 
      "osProfile": { 
       "computerName": "[parameters('virtualMachineName')]", 
       "adminUsername": "[parameters('adminUsername')]", 
       "adminPassword": "[parameters('adminPassword')]" 
      }, 
      "storageProfile": { 
      "imageReference": { 
       "offer": "[concat(parameters('offer'))]", 
       "sku": "[concat(parameters('offer'))]", 
       "version": "latest" 
      } 
      }, 
      "osDisk": { 
      "vhd": { 
       "name": "[variables('vmosidiskname')]", 
       "uri": "[concat('http://', parameters('storageAccountName'), '.blob.core.windows.net/', variables('stdvhdcontainername'),'/', variables('vmosidiskname'), '.vhd')]" 
      }, 
      "name": "[parameters('virtualMachineName')]" 
      } 
      } 
     }, 
     { 
      "name": "[concat('shutdown-computevm-', parameters('virtualMachineName'))]", 
      "type": "Microsoft.DevTestLab/schedules", 
      "apiVersion": "2017-04-26-preview", 
      "location": "[parameters('location')]", 
      "properties": { 
      "status": "[parameters('autoShutdownStatus')]", 
      "taskType": "ComputeVmShutdownTask", 
      "dailyRecurrence": { 
       "time": "[parameters('autoShutdownTime')]" 
      }, 
      "timeZoneId": "[parameters('autoShutdownTimeZone')]", 
      "targetResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]", 
      "notificationSettings": { 
       "status": "[parameters('autoShutdownNotificationStatus')]", 
       "timeInMinutes": "30" 
      }, 
       "dependsOn": [ 
       "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]" 
       ] 
      } 
     }, 

     { 
      "name": "[parameters('networkInterfaceName')]", 
      "type": "Microsoft.Network/networkInterfaces", 
      "apiVersion": "2016-09-01", 
      "location": "[parameters('location')]", 
      "dependsOn": [ 
      "[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]" 
      ], 
     "properties": { 
      "ipConfigurations": [ 
      { 
       "name": "ipconfig1", 
       "properties": { 
       "subnet": { 
        "id": "[variables('subnetRef')]" 
       }, 
       "privateipaddress": "[concat(parameters('ipaddress'))]", 
       "privateIPAllocationMethod": "static" 
       } 
      } 
      ] 
     } 

     } 


    ], 
    "outputs": { 

     "adminUsername": { 
      "type": "string", 
      "value": "[parameters('adminUsername')]" 
      } 
     } 
} 

라인 162에서, ,을 잃어 버렸다. 리소스 Microsoft.Compute/virtualMachines, Microsoft.DevTestLab/schedules, Microsoft.Network/networkInterfaces은 병렬입니다. 그러나 템플릿에 Microsoft.Compute/virtualMachines이 포함되어 있으므로 오류 로그 with the name 'Properties' already exists이 표시됩니다.

참고 : 기본값을 확인해야합니다. 대소 문자를 구분하므로주의하십시오.

업데이트 : Ipconfigurations가 잘못 , 그것은 다음과 같이한다 :

"properties": { 
     "ipConfigurations": [ 
      { 
      "name": "ipconfig1", 
      "properties": { 
       "privateIPAllocationMethod": "Dynamic", 
       "publicIPAddress": { 
       "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]" 
       }, 
       "subnet": { 
       "id": "[variables('subnetRef')]" 
       } 
      } 
      } 

업데이트 2 : 나를 위해

template.jsonparameters.json 작품. 어쩌면이 예제에 따라 템플릿을 수정할 수 있습니다.