Before creating an image from the source virtual machine, the virtual machine must first be deallocated and marked as generalized in Azure:
- Confirm the myVM2 virtual machine has been shut down by running the Get-AzureRmVm command:
Get-AzureRmVm -Name MyVM2 -ResourceGroupName VMLab -status
- Stop and deallocate the virtual machine by running the following command:
Stop-AzureRmVm -ResourceGroupName VMLab -Name myVM2 -Force
- Run the Get-AzureRmVm command to be sure the virtual machine is stopped and deallocated:
Get-AzureRmVm -Name MyVM2 -ResourceGroupName VMLab -status
- Once the virtual machine has stopped and shows deallocated when you run Get-AzureRmVm, set its status to generalized using the Set-AzureRmVm command:
Set-AzureRmVM -ResourceGroupName VMLab -Name myVM2 -Generalized
- Running the preceding command deallocates the source virtual machine and marks it as generalized, preparing it for the imaging process. Confirm that the machine is generalized by running the Get-AzureRmVm command:
Get-AzureRmVm -Name MyVM2 -ResourceGroupName VMLab -status
You should see VM generalized as one of the statuses listed.