Make sure the Lun number is different from the existing data disk lun number
Detaching previous data disk while adding new Data Disk to Virtual Machine .
I am attaching new data disk to my windows VM but my previously added disk has been removed (Dettached) automatically so how can I solve this problem please help me on this .
Below is my ARM template for Adding new disk to VM :
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "String"
},
"diskName": {
"type": "String"
}
},
"resources": [{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2019-07-01",
"name": "[parameters('vmName')]",
"location": "[resourceGroup().location]",
"properties": {
"storageProfile": {
"dataDisks": [{
"lun": 0,
"name": "[parameters('diskName')]",
"createOption": "attach",
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks/', parameters('diskName'))]"
}
}
]
}
},
"dependsOn": ["[resourceId('Microsoft.Compute/disks/', parameters('diskName'))]"]
}, {
"type": "Microsoft.Compute/disks",
"apiVersion": "2018-06-01",
"name": "[parameters('diskName')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard_LRS"
},
"properties": {
"creationData": {
"createOption": "Empty"
},
"diskSizeGB": 1023
}
}
]
}
3 answers
Sort by: Most helpful
-
-
deherman-MSFT 37,081 Reputation points Microsoft Employee
2021-02-04T17:43:15.567+00:00 @Dnyaneshwar Surywanshi
Since you are not specifying the previously attached data disk in this ARM template it is getting detached, you need to specify both disks in your ARM template. I see you also asked this on Stack Overflow and got an answer for this. Linking to that thread incase others face this issue in the future. -
Carl Trevett 1 Reputation point
2021-04-06T09:36:32.457+00:00 @Dnyaneshwar Surywanshi did you ever find an answer to your question? I am trying to figure out the same as I do not want to declare existing data disks only attach a new one