Create a Windows Virtual Machine Image in Azure

1.5 hours
  • 4 Learning Objectives

About this Hands-on Lab

When architecting solutions in the cloud that leverage compute, it is very common to need to rapidly deploy Windows or Linux servers, which fit a specific purpose.

VM images allow you to have a Windows or Linux server, which is pre-configured with applications, software, security, and more. We can then speed up (and automate) the deployment of VMs, which are built from these images and are ready for use.

Within this lab, you’ll gain experience creating a custom VM image from a Windows virtual machine.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Configure a Virtual Machine with IIS

Use the Azure Portal to perform the following tasks. Please log in with the credentials provided to you for this lab.

Please be aware you will need an RDP client to connect to the Windows server. To connect to vm1, use the credentials provided on the lab page.

Connect to VM1 Using RDP

  1. Navigate to the Virtual Machines services page.
  2. Open the existing VM called vm1.
  3. Click on the Connect option in the command bar, and select RDP.
  4. Use the RDP file with your preferred RDP client.

Note: You may choose to copy the public IP address and connect via RDP manually with your RDP client, instead of using the RDP file.

Configure a Web Server

  1. Click Start, Windows PowerShell, then Windows PowerShell.
  2. Type the command: Install-WindowsFeature -name Web-Server -IncludeManagementTools

Create a Basic HTML Page

  1. Click Start, Windows PowerShell, then Windows PowerShell.
  2. Type the command: ConvertTo-Html -InputObject (Get-Date) | Out-File C:inetpubwwwrootindex.html

You can test that the webserver is working by opening http://locahost in Internet Explorer. It should display the test HTML page you just created (date-time).

Remain connected to the server by RDP for the next task.

Generalize the Windows Server

Ensure you are still connected to VM1 using RDP, as per the previous task.

Perform Sysprep

  1. Right-click the start menu.
  2. Click on Run.
  3. Type the following: %WINDIR%system32sysprep.
  4. Click OK to open the folder.
  5. Double-click on the sysprep.exe file.
  6. Use the following settings:
    • System Cleanup Action: Enter System Out-of-Box Experience (OOBE)
    • Generalize: tick the tickbox
    • Shutdown Options: Shutdown
    • NOTE: When you click OK, the computer will generalize and then shutdown
  7. Click OK.

Note: The above task can be completed in with the following command-line option if preferred: %WINDIR%system32sysprepsysprep.exe /generalize /shutdown /oobe.

Create an Image of the Virtual Machine

Use the Azure Portal to perform the following tasks. Please login with the credentials provided to you for this lab.

Convert VM1 to an Image

  1. Navigate to the Virtual Machines services page.
  2. Open the existing VM called vm1.
  3. Check that the Status is showing as stopped.
  4. Use the RDP file with your preferred RDP client.
  5. Click on the Capture option in the command menu, and use the following settings:
    • Name: vmimage1
    • Resource group: leave the default selected
    • Automatically delete this virtual machine: no
    • Type the virtual machine name: vm1
      1. Click on Create.

Note: You will no longer be able to start vm1 after completing this step.

Create a VM using the VM Image

Use the Azure Portal to perform the following tasks. Please login with the credentials provided to you for this lab.

Create a VM from the Image

  1. Navigate to the Images services page.
  2. Click on vmimage1, which we just created.
  3. Click on the + Create VM option in the command menu, and use the following settings:
    • Basics
      • Subscription: leave as-is
      • Resource group: leave as-is
      • Virtual machine name: vm2
      • Region: leave as-is
      • Availability options: none
      • Image: leave as-is
      • Size: B2s
      • Administrator account: use the provided VM credentials
      • Public inbound ports: none
      • License Type: Windows Server
      • Would you like to use an existing Windows Server license?: No
        1. Click on Next: Disks.
    • Disks
      • Leave as-is
        1. Click on Next: Networking
    • Networking
      • Virtual network: vnet1
      • Subnet: subnet1
      • Public IP: leave as-is
      • NIC network security group: None
      • Click on Review + create.
        1. Click on Create.

Note: We have network security already associated with vnet1. This will allow RDP access to vm2.

Test the VM

  1. Connect to the VM using the steps followed earlier.
    Ensure you use the new public IP address for vm2.
  2. Once connected, you can verify the VM is created from the image by performing the following test:
    • Test: Open http://localhost in Internet Explorer
      Result: You should see the page we created earlier.

The above test validates that your new server has (a) IIS configuration from vm1, and (b) the index.html file you generated on vm1.

Additional Resources

You've recently been hired as a solution architect by The Pupper Camp (TPC). The Pupper Camp is a dog services company that works across the globe.

Your IT manager has asked you to provide a proof-of-concept virtual machine image for a website that TPC needs to scale rapidly.

You will need to create a VM image with IIS (Web Server) installed, including a test HTML file. This image must then be used to demonstrate the deployment of a virtual machine using your image.

Note: When creating a VM using the VM Image, choose License Type: Windows Server. On the question Would you like to use an existing Windows Server license?: choose No.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?