Updating data disk size #8512
-
In doing a comparison of bicep to terraform, I'm attempting to validate how the features compare. In both bicep and terraform, I am able to create a VM with a data disk attached. Then, when attempting to update the size of the attached data disk the behaviors are different. In terraform, you can update the size (say from 32GB to 64GB). When doing so and applying, it will stop the VM, update the disk, and start it again. In bicep, if you attempt to do this it gets an error: Interestingly, in the Azure Portal, you can resize the disk and the machine never restarts. I would have expected that bicep would behave more like the portal here than terraform. Is this the expected behavior of bicep? If so, how should one go about using bicep to update this disk size similar to what terraform does without the need to call azure directly and do something like |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It turns out I've answered my own question. When creating a VM, what I would consider the "default" way to created data disks is part of the vm like: resource linuxVM 'Microsoft.Compute/virtualMachines@2022-03-01' = {
name: 'myvm'
properties: {
storageProfile: {
dataDisks: [
{
name: 'datadisk0'
createOption: 'Empty'
diskSizeGB: managed_data_disk_size
lun: 11
managedDisk: {
storageAccountType: managed_data_disk_type
}
}
]
}
}
}] When doing this and changing the disk size it fails to update. However, if you create the disk and then attach it to the vm, then the update will succeed. Example: resource data_disk 'Microsoft.Compute/disks@2022-03-02' = {
name: 'datadisk0'
location: location
sku: {
name: managed_data_disk_type
}
properties: {
creationData: {
createOption: 'Empty'
}
diskSizeGB: managed_data_disk_size
}
}]
resource linuxVM 'Microsoft.Compute/virtualMachines@2022-03-01' = {
name: 'myvm'
properties: {
storageProfile: {
dataDisks: [
{
createOption: 'Attach'
lun: 11
managedDisk: {
id: data_disk.id
}
}
]
}
}
}] |
Beta Was this translation helpful? Give feedback.
-
Yeah, but if the VM has already datadisk attached, and you'd like to add additional one, the current one will be detached :( |
Beta Was this translation helpful? Give feedback.
It turns out I've answered my own question.
When creating a VM, what I would consider the "default" way to created data disks is part of the vm like:
When doing this and changing the disk size it fails to update.
However, if you create the disk and then attach it to the vm, then the update will succe…