title: How do I have conditional copy statement in ARM template
body: <p>I see some examples and answers how to do conditional copy but none seems to be flexible enough to have both number and sizes of disks to be flexible. My template expects parameter which identifies type of storage and size of disk separated by <code>-</code> like below </p>
  
  <pre><code>DataDiskArray: {
  value: [
     "Standard_LRS-64",
     "Standard_LRS-1036"
   ] 
  }
  </code></pre>
  
  <p>It works fine as long as I have at least one disk but I'm having trouble understanding how do I do that when there is no data disks needed at all like </p>
  
  <pre><code>DataDiskArray: {
  value: [ ] 
  }
  </code></pre>
  
  <p>I put <code>copy[]</code> statement into variable but it still being evaluated and fails</p>
  
  <pre><code>"dataDisks": {
              "copy": [
                  {
                      "name": "dataDisks",
                      "count": "[if(equals(length(parameters('DataDiskArray')),0), 1, length(parameters('DataDiskArray')))]",
                      "input": {
                          "caching": "ReadWrite",
                          "diskSizeGB": "[split(parameters('DataDiskArray')[copyIndex('dataDisks')],'-')[1]]",
                          "lun": "[copyIndex('dataDisks')]",
                          "name": "[concat(parameters('VirtualMachineName'), '-DDisk', string(add(copyIndex('dataDisks'),1)))]",
                          "managedDisk": {
                              "storageAccountType": "[split(parameters('DataDiskArray')[copyIndex('dataDisks')],'-')[0]]"
                          },
                          "createOption": "Empty"
                      }
                  }
              ]
  </code></pre>
  
  <p>Resource Deployment inside VM resource</p>
  
  <pre><code>"dataDisks": "[if(equals(length(parameters('DataDiskArray')),0),json('null'),variables('dataDisks'))]"
  </code></pre>