lundi 31 juillet 2017

using conditional IF statements in arm templates for properties,

I have a situation where I want to only add a property to a VM if a condition is met. For example if I want to add an availability set property to a machine then do this : Below I ONLY what to execute the availability set statement if a condition is TRUE, can you do this in an ARM template? eg if a value is true then do this line, if not skip?

 {
  "name": "[parameters('ComputerName')]",
  "type": "Microsoft.Compute/virtualMachines",
  "location": "[parameters('location')]",
  "apiVersion": "2017-03-30",
  "dependsOn": [
    "[resourceId('Microsoft.Network/networkInterfaces', variables('1stNicName'))]",
    "[resourceId('Microsoft.Network/networkInterfaces', variables('2ndicName'))]"
  ],
  "tags": {
    "displayName": "[parameters('ComputerName')]"
  },

  "properties": 

{
"availabilitySet": {
      "id": "[resourceId('Microsoft.Compute/availabilitySets',variables('availabilitySetName'))]"
    },


 "hardwareProfile": {
      "vmSize": "[parameters('serverVmSize')]"


 },
    "osProfile": {
      "computerName": "[parameters('serverName')]",
      "adminUsername": "[parameters('adminUsername')]",
      "adminPassword": "[parameters('adminPassword')]"
    },

Aucun commentaire:

Enregistrer un commentaire