Creating a custom image skips the extra attached disk

Reitse Eskens 21 Reputation points MVP
2020-04-08T09:25:30.563+00:00

I've created a VM in a DevTest lab. This VM has it's main OS disk and a second data disk attached.

When i'm creating a custom image, all is well. But when i create a new VM based on the custom image, the extra attached disk isn't created for the new VM's. In our case the new VM's are less usefull because the extra disk is needed.

How can we create a custom image that in some way contains the extra attached disk?

Azure DevTest Labs
Azure DevTest Labs
An Azure service that is used for provisioning development and test environments.
255 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. kobulloc-MSFT 23,341 Reputation points Microsoft Employee
    2020-04-09T18:04:05.313+00:00

    How are you creating your custom images? If you create a custom image from a VM, the custom image will include the OS disk and all the data disks attached to the virtual machine.

    https://learn.microsoft.com/en-us/azure/lab-services/devtest-lab-create-custom-image-from-vm-using-portal

    Step 7
    "On the Custom image pane, enter a name and description for your custom image. This information is displayed in the list of bases when you create a VM. The custom image will include the OS disk and all the data disks attached to the virtual machine."

    Additionally, you can add a data disk to a virtual machine:

    https://azure.microsoft.com/en-us/updates/azure-devtest-labs-attach-additional-data-disk-to-your-lab-vm/

    https://learn.microsoft.com/en-us/rest/api/dtl/virtualmachines/adddatadisk

    0 comments No comments

  2. Reitse Eskens 21 Reputation points MVP
    2020-04-10T11:59:47.61+00:00

    Hi @Anonymous thanks for reaching out.

    As that is the only way to create a custom image, that is the procedure we follow.

    Tested today if it makes a difference to make the image whilst the VM is running or not.

    No difference at all. In both cases no data disk (and therefore a VM that's unusable).

    0 comments No comments

  3. Reitse Eskens 21 Reputation points MVP
    2020-04-10T18:22:02.727+00:00

    Addition. I've created a custom image with the option "I have run sysprep on the virtual machine." set to On.
    This results in the following message: The custom image will include the OS disk and all the data disks attached to the virtual machine.

    Thing is, as far as i know, i haven't run anything resembling sysprep on the machine. In the end, when i deploy a new vm based on this ci, i get the following error:

    OS Provisioning for VM 'reitseeskens002' did not finish in the allotted time. However, the VM guest agent was detected running. This suggests the guest OS has not been properly prepared to be used as a VM image (with CreateOption=FromImage). To resolve this issue, either use the VHD as is with CreateOption=Attach or prepare it properly for use as an image:

    So i'm still left with a useless VM i think or at least one that's not trusted at first sight.

    0 comments No comments