In Azure marketplace there are many different templates available for OS deployment. These are general purpose templates. But in corporate environment administrators use custom images for their OS deployments. These images are usually fine tuned for corporate requirements. Azure also allow to do the same. In Azure we can create custom images according to our requirements and use it to deploy virtual machines. In this demo I am going to demonstrate how to create custom image and how we can use it to deploy new virtual machines.
1. Log in to Azure portal as Global Admin
2. Create a Virtual Machine with your OS requirements.
3. In my demo, I am using a VM with windows server 2016 datacenter.
4. In this VM, I have installed XPS viewer, Adobe Reader and created a folder in C:\ called “CompanyDocs”
5. Once customization done, run %windir%\system32\sysprep\sysprep.exe as a administrator from command line. (with in VM)
6. In new window, select OOBE and Generalize option. Also, for shutdown option, select Shutdown. This will generalize the VM image.
7. Once it’s done sysprep, system shutdown the VM.
8. Go to VM properties page (click on relevant virtual machine name from VM list) and click on Capture icon.
9. In new window, provide name for image and select resource group to save the image. Also make sure to select Automatically delete this virtual machine after creating the image. Then click on Create
10. Once job is completed, go to All Service | Images
11. In there now we can see the image we created.
12. Click on the image and go to its properties page.
13. Then click on Create VM option.
14. Then create VM with the size and other configurations you need.
15. Once VM is created, lets log in and see if it’s got all the customization I made.
As we can see, it is done the job as expected. This marks the end of this blog post. Hope now you have better understanding how to create custom images and how to use it in azure. If you have any questions feel free to contact me on rebeladm@live.com also follow me on twitter @rebeladm to get updates about new blog posts.