question

Engelsmann avatar image
0 Votes"
Engelsmann asked srbose-msft edited

Error "" in CLI create Compute (not through MLworkspace web interface)

I want to create a Compute resource in my ML workspace. In the MLW web interface, I stop where I can download ARM template, download and unpack on my local Debian machine. No editing of the downloaded templates.

Then I submit this command in terminal (CLI):

$ az deployment group create
       --resource-group "DP-100"     
       --template-file /home/morten/Dropbox/Python/Certificering/DP-100/ml-compute-instance-template/template.json     
       --parameters @/home/morten/Dropbox/Python/Certificering/DP-100/ml-compute-instance-template/parameters.json

I provide the adminUserName when prompted, but then the following error is returned:
```
{"error":{"code":"InvalidTemplate","message":"Deployment template validation failed: 'Template parameter JToken type is not valid. Expected 'String, Uri'. Actual 'Boolean'. Please see https://aka.ms/resource-manager-parameter-files for usage details.'.","additionalInfo":[{"type":"TemplateViolation","info":{"lineNumber":58,"linePosition":18,"path":"properties.template.parameters.sshAccess"}}]}}
```
My solution was to continue past the download option in web interface. Creating "manually" in MLW web interface works like a charm. But I wanted this to run as a script, and for that I need ARM templates.

template.json
```
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workspaceName": {
"type": "string",
"metadata": {
"description": "Specifies the name of the Azure Machine Learning service workspace."
}
},
"computeInstanceName": {
"type": "string",
"metadata": {
"description": "Specifies the name of the Compute Instance to create under Azure Machine Learning workspace."
}
},
"location": {
"type": "string",
"allowedValues": [
"australiaeast",
"brazilsouth",
"canadacentral",
"centralus",
"centraluseuap",
"eastasia",
"eastus",
"eastus2",
"francecentral",
"japaneast",
"koreacentral",
"northcentralus",
"northeurope",
"southeastasia",
"southcentralus",
"uksouth",
"westcentralus",
"westus",
"westus2",
"westeurope"
],
"metadata": {
"description": "Specifies the location for all resources."
}
},
"adminUserName": {
"type": "string",
"metadata": {
"description": "Name of the administrator user account which can be used to SSH to nodes."
}
},
"adminUserSshPublicKey": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Specifies the SSH Public Key to use for SSH access to the Compute Instance."
}
},
"sshAccess": {
"type": "string",
"defaultValue": "Disabled",
"allowedValues": [
"Disabled",
"Enabled"
],
"metadata": {
"description": "Specifies whether SSH access should be enabled for compute instance"
}
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_DS3_v2",
"allowedValues": [
"Standard_D1_v2",
"Standard_D2_v2",
"Standard_D3_v2",
"Standard_D4_v2",
"Standard_D11_v2",
"Standard_D12_v2",
"Standard_D13_v2",
"Standard_D14_v2",
"Standard_DS1_v2",
"Standard_DS2_v2",
"Standard_DS3_v2",
"Standard_DS4_v2",
"Standard_DS5_v2",
"Standard_DS11_v2",
"Standard_DS12_v2",
"Standard_DS13_v2",
"Standard_DS14_v2",
"Standard_M8-2ms",
"Standard_M8-4ms",
"Standard_M8ms",
"Standard_M16-4ms",
"Standard_M16-8ms",
"Standard_M16ms",
"Standard_M32-8ms",
"Standard_M32-16ms",
"Standard_M32ls",
"Standard_M32ms",
"Standard_M32ts",
"Standard_M64-16ms",
"Standard_M64-32ms",
"Standard_M64ls",
"Standard_M64ms",
"Standard_M64s",
"Standard_M128-32ms",
"Standard_M128-64ms",
"Standard_M128ms",
"Standard_M128s",
"Standard_M64",
"Standard_M64m",
"Standard_M128",
"Standard_M128m",
"Standard_D1",
"Standard_D2",
"Standard_D3",
"Standard_D4",
"Standard_D11",
"Standard_D12",
"Standard_D13",
"Standard_D14",
"Standard_DS15_v2",
"Standard_NV6",
"Standard_NV12",
"Standard_NV24",
"Standard_F2s_v2",
"Standard_F4s_v2",
"Standard_F8s_v2",
"Standard_F16s_v2",
"Standard_F32s_v2",
"Standard_F64s_v2",
"Standard_F72s_v2",
"Standard_NC6s_v3",
"Standard_NC12s_v3",
"Standard_NC24rs_v3",
"Standard_NC24s_v3",
"Standard_NC6",
"Standard_NC12",
"Standard_NC24",
"Standard_NC24r",
"Standard_ND6s",
"Standard_ND12s",
"Standard_ND24rs",
"Standard_ND24s",
"Standard_NC6s_v2",
"Standard_NC12s_v2",
"Standard_NC24rs_v2",
"Standard_NC24s_v2",
"Standard_ND40rs_v2",
"Standard_NV12s_v3",
"Standard_NV24s_v3",
"Standard_NV48s_v3"
],
"metadata": {
"description": "Specifies the VM size of the Compute Instance to create under Azure Machine Learning workspace."
}
}
},
"resources": [
{
"type": "Microsoft.MachineLearningServices/workspaces/computes",
"apiVersion": "2020-02-18-preview",
"name": "[concat(parameters('workspaceName'), '/', parameters('computeInstanceName'))]",
"location": "[parameters('location')]",
"properties": {
"computeType": "ComputeInstance",
"properties": {
"VMSize": "[parameters('vmSize')]",
"applicationSharingPolicy": "Personal",
"sshSettings": {
"adminUserName": "[parameters('adminUserName')]",
"sshPublicAccess": "[parameters('sshAccess')]",
"adminPublicKey": "[parameters('adminUserSshPublicKey')]"
}
}
}
}
]
}
```
parameters.json:
```
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"value": "northeurope"
},
"workspaceName": {
"value": "DP100ML"
},
"computeInstanceName": {
"value": "DP100morten"
},
"vmSize": {
"value": "Standard_DS3_v2"
},
"sshAccess": {
"value": false
}
}
}
```

azure-virtual-machines
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Short version of error message got too short ;-) I should state that the error seems to be `Template parameter JToken type is not valid.`

0 Votes 0 ·

1 Answer

srbose-msft avatar image
1 Vote"
srbose-msft answered Engelsmann commented

@Engelsmann ,

In the error message I can see it says, Expected 'String, Uri'. Actual 'Boolean' and [{"type":"TemplateViolation","info":{"lineNumber":58,"linePosition":18,"path":"properties.template.parameters.sshAccess"}}]}}

According to template.json the object sshAccess is defined as follows:

 "sshAccess": {
 "type": "string",
 "defaultValue": "Disabled",
 "allowedValues": [
 "Disabled",
 "Enabled"
 ],
 "metadata": {
 "description": "Specifies whether SSH access should be enabled for compute instance"
 }
 }

However, in parameters.json, I can see:

 "sshAccess": {
 "value": false
 }

This is a type mismatch that violates the definition of the sshAccess object in template.json. The compiler expected a String value. Instead, it found a Boolean value false supplied in parameters.json.

Can you please try changing the value of sshAccess to one of the allowed values Disabled or Enabled in parameters.json and try again?



Hope this helps!!!

Please "Accept as Answer" if it helped, so that it can help others in the community looking for help on similar topics.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Engelsmann , thank you for your response. true is a Boolean expression. The object sshAccess as defined in the template.json can only accept string values [which are identified as a sequence of alpha numeric characters within quotes ("")]. Also, the allowed values of the sshAccess object according to template.json are "Disabled" and "Enabled":

"sshAccess": {
"type": "string",
"defaultValue": "Disabled",
"allowedValues": [
"Disabled",
"Enabled"
],
"metadata": {
"description": "Specifies whether SSH access should be enabled for compute instance"
}
},



So in the parameters.json file, you can only mention sshAccess object as one of the following two options:

"sshAccess": {
"value": "Disabled"
}

OR

"sshAccess": {
"value": "Enabled"
}

1 Vote 1 ·

Error persists (identical error message) after changing false to true:
"sshAccess": { "value": true }

Is it something about not requesting SSH in the CLI command? I issue this command:

$ az deployment group create --resource-group "DP-100" --template-file /home/morten/Dropbox/Python/Certificering/DP-100/ml-compute-instance-template/template.json --parameters @/home/morten/Dropbox/Python/Certificering/DP-100/ml-compute-instance-template/parameters.json

0 Votes 0 ·