azure-xplat-cli
azure-xplat-cli copied to clipboard
read-only property 'type' of <region>
CLI Version: 0.10.6 (node: 4.2.6) OS Type: Ubuntu 16.04 Installation via: npm Mode: ARM Environment: AzureCloud
azure group create
throwing error about read-only property 'type' of
azure group create -n nsgvmss595 -d nsgvmss595 -l japanwest -f mainTemplate.json -e tmp/nsgvmss595.json info: Executing command group create
- Getting resource group nsgvmss595
- Updating resource group nsgvmss595 info: Updated resource group nsgvmss595 error: Cannot assign to read only property 'type' of japanwest error: Error information has been recorded to /home/negat/.azure/azure.err error: group create command failed
Error stack trace:
2016-10-27T22:53:59.951Z: { [TypeError: Cannot assign to read only property 'type' of japanwest] stack: [Getter/Setter], __frame: { name: 'missingParameters', line: 451, file: '/usr/local/lib/node_modules/azure-cli/lib/commands/arm/group/groupUtils.js', prev: { name: 'createDeploymentParameters', line: 242, file: '/usr/local/lib/node_modules/azure-cli/lib/commands/arm/group/groupUtils.js', prev: [Object], calls: 1, active: false, offset: 21, col: 17 }, calls: 1, active: true, offset: 2, col: 4 }, rawStack: [Getter] } TypeError: Cannot assign to read only property 'type' of japanwest <<< async stack >>> at missingParameters (/usr/local/lib/node_modules/azure-cli/lib/commands/arm/group/groupUtils.js:453:5) at createDeploymentParameters (/usr/local/lib/node_modules/azure-cli/lib/commands/arm/group/groupUtils.js:263:18) at exports_createDeployment__1 (/usr/local/lib/node_modules/azure-cli/lib/commands/arm/group/groupUtils.js:75:28) at group_createResourceGroup__3 (/usr/local/lib/node_modules/azure-cli/lib/commands/arm/group/group.js:132:18) at __1 (/usr/local/lib/node_modules/azure-cli/lib/commands/arm/group/group.js:61:32) <<< raw stack >>> at /usr/local/lib/node_modules/azure-cli/lib/commands/arm/group/groupUtils.js:478:45 at Array.forEach (native) at ___ (/usr/local/lib/node_modules/azure-cli/lib/commands/arm/group/groupUtils.js:476:29) at ___ (/usr/local/lib/node_modules/azure-cli/node_modules/streamline/lib/callbacks/runtime.js:111:13) at /usr/local/lib/node_modules/azure-cli/node_modules/streamline/lib/callbacks/runtime.js:99:14 at Object.__g.trampoline.flush (/usr/local/lib/node_modules/azure-cli/node_modules/streamline/lib/callbacks/runtime.js:24:29) at ___ (/usr/local/lib/node_modules/azure-cli/node_modules/streamline/lib/callbacks/runtime.js:123:61) at /usr/local/lib/node_modules/azure-cli/node_modules/azure-arm-resource/lib/resource/operations/resourceGroups.js:1041:12 at retryCallback (/usr/local/lib/node_modules/azure-cli/node_modules/ms-rest/lib/filters/exponentialRetryPolicyFilter.js:140:9) at handleRedirect (/usr/local/lib/node_modules/azure-cli/node_modules/ms-rest/lib/filters/redirectFilter.js:36:9)
@gatneil - Can you also provide the template file and a parameter file with dummy values. That will help us debug the issue. Without it, it is hard to say what went wrong.
tmp/nsgvmss595.json:
{"username": "negat", "autoscaleDefault": "1", "scaleOutInterval": "1", "vmSku": "Standard_D1_v2", "authenticationType": "password", "autoscaleMin": "1", "vmssName": "nsgvmss595", "pipName": "pip", "image": "Ubuntu16.04.0-LTS", "pipLabel": "nsgvmss595", "baseUrl": "https://raw.githubusercontent.com/gatneil/portal/master", "scaleOutCPUPercentageThreshold": "75", "instanceCount": 2, "autoscaleYesOrNo": "No", "location": "japanwest", "scaleInCPUPercentageThreshold": "25", "autoscaleMax": "10", "osType": "Linux", "password": "REDACTED", "sshPublicKey": "", "scaleInInterval": "1"}
mainTemplate.json:
{
"$schema":"http://schema.management.azure.com/schemas/2015-01-01-preview/deploymentTemplate.json",
"contentVersion":"1.0.0.0",
"parameters":{
"location": {
"type": "string",
"metadata": {
"description": "location of resources"
}
},
"pipName": {
"type": "string"
},
"pipLabel": {
"type": "string"
},
"vmSku": {
"type": "string",
"defaultValue": "Standard_D1_v2",
"metadata": {
"description": "Size of VMs in the VM Scale Set."
}
},
"osType": {
"type": "string",
"allowedValues": ["Windows", "Linux"]
},
"image": {
"type": "string",
"metadata": {
"description": "The os disk image for the VMs in the scale set."
}
},
"vmssName": {
"type": "string",
"metadata": {
"description": "String used as a base for naming resources. Must be 3-61 characters in length and globally unique across Azure. A hash is prepended to this string for some resources, and resource-specific information is appended."
},
"maxLength": 61
},
"instanceCount": {
"type": "string",
"metadata": {
"description": "Number of VM instances (100 or less)."
}
},
"authenticationType": {
"type": "string",
"allowedValues": ["password", "sshPublicKey"],
"metadata": {
"description": "password or sshPublicKey"
}
},
"username": {
"type": "string",
"metadata": {
"description": "Admin username on all VMs."
}
},
"password": {
"defaultValue": "",
"type": "securestring",
"metadata": {
"description": "Admin password on all VMs."
}
},
"sshPublicKey": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "ssh public key for connecting to VMs."
}
},
"autoscaleYesOrNo": {
"type": "string",
"defaultValue": "No",
"allowedValues": ["Yes", "No"]
},
"autoscaleMin": {
"type": "string",
"defaultValue": "1"
},
"autoscaleMax": {
"type": "string",
"defaultValue": "10"
},
"autoscaleDefault": {
"type": "string",
"defaultValue": "1",
"metadata": {
"description": "Autoscale will ensure you have at least this many VMs, even if it cannot read from the diagnostics Storage Table."
}
},
"scaleOutCPUPercentageThreshold": {
"type": "string",
"defaultValue": "75"
},
"scaleOutInterval": {
"type": "string",
"defaultValue": "1"
},
"scaleInCPUPercentageThreshold": {
"type": "string",
"defaultValue": "25"
},
"scaleInInterval": {
"type": "string",
"defaultValue": "1"
},
"baseUrl": {
"type": "string",
"metadata": {
"artifactsBaseUrl": "Base URL of the VMSS Template gallery package"
},
"defaultValue": "GETS REPLACED"
}
},
"variables":{
"baseTemplateUri":"[concat(parameters('baseUrl'), '/autoscale')]",
"parametersAutoscaleNo": {
"username": {"value": "[parameters('username')]"},
"pipName": {"value": "[parameters('pipName')]"},
"pipLabel": {"value": "[parameters('pipLabel')]"},
"instanceCount": {"value": "[parameters('instanceCount')]"},
"authenticationType": {"value": "[parameters('authenticationType')]"},
"vmssName": {"value": "[parameters('vmssName')]"},
"osType": {"value": "[parameters('osType')]"},
"image": {"value": "[parameters('image')]"},
"vmSku": {"value": "[parameters('vmSku')]"},
"location": {"value": "[parameters('location')]"},
"password": {"value": "[parameters('password')]"},
"sshPublicKey": {"value": "[parameters('sshPublicKey')]"}
},
"parametersAutoscaleYes": {
"username": {"value": "[parameters('username')]"},
"pipName": {"value": "[parameters('pipName')]"},
"pipLabel": {"value": "[parameters('pipLabel')]"},
"autoscaleDefault": {"value": "[parameters('autoscaleDefault')]"},
"instanceCount": {"value": "[parameters('instanceCount')]"},
"scaleInInterval": {"value": "[parameters('scaleInInterval')]"},
"scaleOutInterval": {"value": "[parameters('scaleOutInterval')]"},
"authenticationType": {"value": "[parameters('authenticationType')]"},
"autoscaleMin": {"value": "[parameters('autoscaleMin')]"},
"vmssName": {"value": "[parameters('vmssName')]"},
"autoscaleMax": {"value": "[parameters('autoscaleMax')]"},
"osType": {"value": "[parameters('osType')]"},
"image": {"value": "[parameters('image')]"},
"scaleOutCPUPercentageThreshold": {"value": "[int(parameters('scaleOutCPUPercentageThreshold'))]"},
"vmSku": {"value": "[parameters('vmSku')]"},
"location": {"value": "[parameters('location')]"},
"scaleInCPUPercentageThreshold": {"value": "[int(parameters('scaleInCPUPercentageThreshold'))]"},
"password": {"value": "[parameters('password')]"},
"sshPublicKey": {"value": "[parameters('sshPublicKey')]"}
}
},
"resources":
[
{
"name":"scaleSetPortalDeployment",
"type":"Microsoft.Resources/deployments",
"apiVersion":"2015-11-01",
"properties":{
"mode":"Incremental",
"templateLink":{
"uri":"[concat(variables('baseTemplateUri'), parameters('autoscaleYesOrNo'), '.json')]",
"contentVersion":"1.0.0.0"
},
"parameters": "[variables(concat('parametersAutoscale', parameters('autoscaleYesOrNo')))]"
}
}
]
}
Based on the error message
"Cannot assign to read only property 'type' of japanwest",
"japanwest" is the value provided to the parameter location. So, can you take a look at the schema for this template. I am pretty sure the schema for location would have "readOnly": true
; which would be incorrect.
From the content that you pasted in the above comment, it looks like this is the schema
http://schema.management.azure.com/schemas/2015-01-01-preview/deploymentTemplate.json
However, doing a GET or pasting it in the browser provides the following error. It would be nice if you can verify that schema or send that schema internally via email (if sensitive).
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>BlobNotFound</Code>
<Message>The specified blob does not exist. RequestId:164df870-0001-000d-64aa-30e0fc000000 Time:2016-10-27T23:36:46.1337525Z</Message>
</Error>
Interesting. It seems I'm pointing to a schema that doesn't exist! My bad. Can we add a check for this so the error can be more clear?
@vivsriaus @ravbhatnagar - Can we handle such errors in a better way?
The error presists even when I update the schema to point at an existing one. I think the error actually comes about when the parameters file isn't in the expected format (I previously just had a file of {'param': 'val'}, which I had seen used before. After updating to {'$schema': <parameter_file_schema>, 'contentVersion': '1.0.0.0', 'parameters': {'param': 'val'}}, it seems to work
@gatneil - Yes this is expected. You either need to pass the $schems, contentVersion etc headers or just passing in "parameters" : { 'param1': 'val1' } Only passing in the name value pairs won't work. We will see if we can improve the error message though.