1

I created 2 VMs, one is the domain controller, another is for hosting the applications, then I created 2 images from these VMs by following this article. But now I cannot create VM from the images, even manually create the image from the Azure portal. what I missed?

Here is the code looks like:

foreach($a in $arr){
 $a = $a.Trim()

 New-AzVM -ResourceGroupName $env:groupName -Name dc$a -ImageName $env:dcImageName -Location $env:location -VirtualNetworkName vNet$a -SubnetName subnet$a -SecurityGroupName ngs$a -PublicIpAddressName publicIp$a -OpenPorts 3389 -Credential $cred 

 New-AzVM -ResourceGroupName $env:groupName -Name app$a -ImageName $env:appImageName -Location $env:location -VirtualNetworkName vNet$a -SubnetName subnet$a -SecurityGroupName ngs$a -PublicIpAddressName publicIp$a -OpenPorts 3389 -Credential $cred 
}

The error is:

##[error]Long running operation failed with status 'Failed'. Additional Info:'OS Provisioning for VM 'dclab1' did not finish in the allotted time. The VM may still finish provisioning successfully. Please check provisioning state later. Also, make sure the image has been properly prepared (generalized).

Best Regards, Sue.

Sue Su
  • 301
  • 1
  • 2
  • 11
  • Do you have generalized the VM? Do you create VM from that image with credentials?https://learn.microsoft.com/en-us/azure/virtual-machines/windows/tutorial-custom-images#create-vms-from-the-image – Nancy Nov 22 '19 at 08:38
  • Yes, I did. I generalized the VM by the sysprep.exe. and executed the command Set-AzVM ` -ResourceGroupName myResourceGroup ` -Name myVM -Generalized – Sue Su Nov 22 '19 at 08:40
  • 1
    If possible, please, share the error which you are getting as result of your commands or on Azure Portal. – Ivan Ignatiev Nov 22 '19 at 09:38
  • the error shared. – Sue Su Nov 25 '19 at 01:13

2 Answers2

1

Currently, I've been given up this solution, I use the snapshot of VHD to create VM instead of creating VM from the images.

Sue Su
  • 301
  • 1
  • 2
  • 11
0

From the error message, It seems that your image is not properly prepared (generalized).

Time might be the issue. You could try to generalize the Windows VM using SysprepSysprep. Normally it takes 10 - 15 minutes, you should wait for enough time for the Sysprep. When the status is changed to stop in the Azure portal, you could deallocate and mark the VM as generalized.

Also, make sure you have selectd each of the steps during the generalization process:

enter image description here

Nancy
  • 26,865
  • 3
  • 18
  • 34