I understand there is option to have conditional output for property values, but is it possible to have conditional property itself. For example I have template which creates Microsoft.Compute/VirtualMachine
and it's the same template for both Windows and Linux. But for windows I need to specify property which do not exist for Linux ("licenseType": "Windows_Server")
. Presense of this property will fail deployment with error The property 'LicenseType' cannot be used together with property 'linuxConfiguration'
I'm trying to figure out if it's possible to have this property included only for Windows images while keeping template the same?
yes it is possible, but hacky. several options:
let me expand number two a bit:
"variables": {
"baseObject": {
"propertyOne": "xxx",
"propertyTwo": "yyy"
},
"additionalObject": {
"optionalProperty": "zzz"
}
}
and then in your object you can do:
"property": "[if(something, variables('baseObject'), # new line for readability
union(variables('baseObject'), variables('additionalObject') ))]"