How to create data disks for azure virtual machines?

I added some virtual machines to virtual machines when creating virtual machines using the following json template.

"variables": {  
"diskArray": [  
{  
"name": "datadisk1",
"lun": 0,   
"vhd": {  
"uri": "[concat('http://', variables('storageAccountName'),'.blob.core.windows.net/vhds/','datadisk1.vhd')]"  
        },  
        "createOption": "Empty",    
        "caching": "ReadWrite",    
        "diskSizeGB": 300    
      },    
      {    
        "name": "datadisk2",
        "lun": 1,
        "vhd": {
          "uri": "[concat('http://', variables('storageAccountName'),'.blob.core.windows.net/vhds/', 'datadisk2.vhd')]"    
        },  
        "createOption": "Empty",    
        "caching": "ReadWrite",    
        "diskSizeGB": 200  
      },  
      {   
        "name": "datadisk3",  
        "lun": 2,  
        "vhd": {  
          "uri": "[concat('http://', variables('storageAccountName'),'.blob.core.windows.net/vhds/', 'datadisk3.vhd')]"  
        },  
        "createOption": "Empty",  
        "caching": "ReadWrite",  
        "diskSizeGB": 100  
      }  
]    
  },    
.....    
.....   
"resources": [  
    {  
      "apiVersion": "2015-06-15",  
      "type": "Microsoft.Compute/virtualMachines",  
      "name": "[concat(parameters('VmPrefix'), copyindex(1))]",  
      "copy": {  
        "name": "Datanode",  
        "count": "[variables('vmcount')]"  
      },  
      "location": "[resourceGroup().location]",  
      "properties": {  
         ......  
         ......  
        "storageProfile": {  
          "imageReference": {  
            ........  
          },  
          "dataDisks":   "[take(variables('diskArray'),parameters('numDataDisks'))]",  
          "osDisk": {  
            .......  
          }  
        }  
    }  
}  
]  

This code works great when creating a single virtual machine, but when creating multiple virtual machines, machines were not created. This is because the vhd created for the datadisks for the first machine is similar to other machines.

Is there a way to create vhd with a different name? I tried to skip the copy index, but it does not work.

+4
source share
1 answer

Of course there is, I will put a link to a template that will do this, and explain how it works. Here is the link.

, copyindex ( - ) , , , copyindex .

, .
.

+2

Source: https://habr.com/ru/post/1671220/


All Articles