给定一个 template.json :
"parameters": {
"virtualMachineName": {
"type": "string"
},
"networkInterfaceName": {
"type": "string"
}
}
如何根据 virtualMachineName 的输入设置 networkInterfaceName?
例如:
New-AzureRmResourceGroupDeployment -Name MyDeployment -TemplateFile .\template.json -TemplateParameterFile .\parameters.json
将提示输入 VirtualMachineName,如果输入了“test-vm”,我们希望 networkInterfaceName 默认为“test-vm-nic”。
我们已经尝试添加这个parameters.json:
"networkInterfaceName": {
"value": "[concat(parameters('virtualMachineName'),'_nic')]"
},
但收到错误:
Error: Code=InvalidResourceName; Message=Resource name
[concat(parameters('virtualMachineName'),'_nic')] is invalid. The
name can be up to 80 characters long. It must begin with a word character,
and it must end with a word character or with '_'. The name may contain word
characters or '.', '-', '_'.