Gre*_*ian 6 azure-resource-manager
我知道可以为属性值提供条件输出,但是可以有条件属性本身。例如,我有创建的模板,Microsoft.Compute/VirtualMachine并且它是Windows和Linux的相同模板。但是对于Windows,我需要指定Linux不存在的属性("licenseType": "Windows_Server")。该属性的存在将导致部署失败,并显示错误The property 'LicenseType' cannot be used together with property 'linuxConfiguration'
我试图弄清楚是否有可能仅在Windows映像中包含此属性,同时保持模板不变?
Gre*_*ian 12
这是我根据之前的答案和评论最终所做的
"isWindowsOS": "[equals(parameters('ImageReferenceOffer'), 'WindowsServer')]"
"properties": {
"licenseType": "[if(variables('isWindowsOS'), 'Windows_Server', json('null'))]",
是的,这是可能的,但是很客气。几种选择:
让我扩大第二位:
"variables": {
"baseObject": {
"propertyOne": "xxx",
"propertyTwo": "yyy
}
"additionalObject: {
"optionalProperty": "zzz"
}
}
Run Code Online (Sandbox Code Playgroud)
然后可以在您的对象中执行以下操作:
"property": "[if(something, variables('baseObject'), # new line for readability
union(variables('baseObject'), variables('additionalObject') ))]"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2033 次 |
| 最近记录: |