Azure – is it possible to use azure managed disks with azure scale sets, as an OS disk

azure

is it possible to make virtual machine scale set using manged disk.
i am trying this in vmss vm profile but keep getting error

"virtualMachineProfile":{
    "storageProfile":{
        "imageReference":{
            "publisher":"Canonical",
            "offer":"UbuntuServer",
            "sku":"14.04.2-LTS",
            "version":"14.04.2-LTS"
        },
        "osDisk":{
            "osType":"Linux",
            "caching":"ReadWrite",
            "createOption":"FromImage",
            "name":"OSDisk",
            "managedDisk":{
                "storageAccountType":"Premium_LRS"
            }
        },
        "dataDisks": [{
            "lun":0,
            "managedDisk":{
                "id":
                "[resourceId('Microsoft.Compute/disks', 'testvm_OsDisk_1_bac5bcaf20ec4cafbb0f452d631fe68f')]"
            },
            "caching":"None",
            "createOption":"Attach"
        }]
    },
    message ": " Parameter 'osDisk.managedDisk.id' is not allowed.

Best Answer

For now, we can't use managed disk to create Azure VM directly.
But we can create a managed image of managed vm or a snapshot via PowerShell, after that we can use this new image to create azure VM.

$vmName = "myVM" 
$rgName = "myResourceGroup" 
$location = "EastUS" 
$imageName = "myImage"
Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName -Force
Set-AzureRmVm -ResourceGroupName $rgName -Name $vmName -Generalized
$vm = Get-AzureRmVM -Name $vmName -ResourceGroupName $rgName
$image = New-AzureRmImageConfig -Location $location -SourceVirtualMachineId $vm.ID 
New-AzureRmImage -Image $image -ImageName $imageName -ResourceGroupName $rgName

enter image description here

More information about generalize vm and create image, please refer to this link.

By the way, the comment you added is right, we can use image in this way.

Related Topic