Friday, February 21, 2020

Windows Custom Image Creation in Azure

If you had already created a Virtual Machine in Azure, you might be aware that Azure Marketplace Images are used to deploy OS (Windows/Linux). What if you need custom Images (Templates in VMware World) with tools and applications that your Organization or Department use. 

Below are steps to create a Custom Image in Azure:
  1. Spin up Virtual Machine using Azure Market Place Image.
  2. Install all the latest patches and service packs (Most of the time it is up to date)
  3. Install all the required Applications and Application Patches.
  4. Harden the server.
  5. Run Sysprep with Generalized and Shutdown the machine.
  6. Convert prepared VM into an image by using the Capture option.
  7. Deploy VMS using the image created.

Here is Virtual Machine Windows 2016 OS which we will use to convert it into a custom image.

Login the machine with admin credentials and perform Steps 2 to 4 in the above steps. 

Go to the Run option within the OS and type Sysprep, which will take you to the folder that got Sysprep Application.

Launch Sysprep.exe (System Preparation Tool), select Out-of-Box-Experience with Generalize option selected and Shutdown option selected.

Sysprep Wizard removes unique identifies like Hostname, SID, OS specific drivers and makes the system ready for an image.

Once the Sysprep is done server will shutdown as the shutdown option was selected during Sysprep. Once the status of the machine changes to Stopped use the Capture option to convert VM into Image.

Image creation blade will ask for Image name, Resource Group, whether VM should be deleted after Image created, Zone Resiliency and VM name which is the name of the VM that we are using for Image creation.

Provide all required details and use Create button the initiate Image creation.

Image creation has 3 steps (Look at the notification in the below screenshot) 1) Stopping the VM (Deallocation) 2) Generalization of VM  3) Create Image.

Once image conversion is done, newly created Image is available in Images service. 
VM creation option is similar to the creation of a new VM from Virtual Machine Service, except the location/region cannot be changed. It picks the same location where you Image is. 

In Order to use Image across the regions, you can use Image Sharing option or Copy this image to other locations.

To create a Virtual Machine from the newly created Image, Go to image and use Create VM to deploy OS for the created image.

Newly created VM vm-2 from the image Win2k16-Image  is running and the Original VM Win2k16 is in Stopped (deallocated) state.

Note: VM that is generalized cannot be reused.

No comments:

Post a Comment