Skip to content

ARM: Add-AzureVMDataDisk requires DiskSizeInGB even for CreateOption attach or fromImage #623

Closed
@colindembovsky

Description

@colindembovsky

When trying to create an Azure VM from existing vhds, I create a config and use Add-AzureVMDataDisk to add in the disk configuration.

$vm = New-AzureVMConfig -VMName "demo" -VMSize $size
$vm = Set-AzureVMOSDisk -VM $vm -Name "os-disk.vhd" -VhdUri $osDiskUri -CreateOption attach -Windows -Caching ReadWrite

However, when I try to attach the existing data disk, I have to specify DiskSizeInGB (the parameter is mandatory):

$vm = Add-AzureVMDataDisk -VM $vm -VhdUri $dataDiskUri -Name "data-disk.vhd" -CreateOption attach -Caching ReadOnly -DiskSizeInGB 200

The command succeeds, but when passing this configuration to New-AzureVM, the operation fails stating that the disk Uri exists and that a non-existing uri should be supplied when creating an empty disk. Similarly, if I supply the data disk uri as sourceImageUri and provide a new uri (so that New-AzureVM copies the disk) I get an error stating that "you cannot specify size and sourceImageUri".

I found that if I set the size of the data disk to null in the config, then the New-AzureVM operation succeeds (for both createOption = attach and createOption = fromImage):

$vm.StorageProfile.DataDisks[0].DiskSizeGB = $null

There are 2 solutions:

  1. The New-AzureVM cmdlet should ignore the size for CreateOption fromImage or attach
  2. The Add-AzureDataDisk cmdlet should not require DiskSizeInGB parameter, setting the value to null if it is not supplied

Metadata

Metadata

Assignees

No one assigned

    Labels

    ComputeService AttentionThis issue is responsible by Azure service team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions