Using Custom Images for a Virtual Machine Scale Set in Azure

1.25 hours
  • 4 Learning Objectives

About this Hands-on Lab

Your company has a custom Linux VM that they want to redeploy to a virtual machine scale set. You must find an efficient way of redeploying this VM without having to manually install all custom packages and settings.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Start Cloud Shell
  1. Click the Cloud Shell icon (>_) in the upper right.
  2. Select Bash.
  3. Click Show advanced settings.
  4. Change Cloud Shell Region to West US.
  5. For Storage account, select Use existing.
  6. For File share, select Create new and give it a name of "fileshare".
  7. Click Create storage.
Set Resource Variables in Cloud Shell
  1. In the Azure portal, click the listed resource group name.
  2. Copy it to your clipboard.
  3. In Cloud Shell, set the RG variable, replacing <RESOURCE_GROUP_NAME> with the name you just copied.
  4. In the Azure portal, click the virtual machine provisioned with this lab.
  5. In the left menu, click Properties.
  6. Scroll down and copy the Resource ID to the clipboard.
  7. In Cloud Shell, set the IMAGE variable, replacing <RESOURCE_ID> with the name you just copied.
Create an Image from the VM
  1. Create an image gallery.
  2. Create an image definition.
  3. Create an image version.
Create a Virtual Machine Scale Set from an Image
  1. In the Azure portal, scroll the listed resources and click the new image definition file.
  2. In the left menu, click Properties.
  3. Scroll down and copy the Resource ID to the clipboard.
  4. In Cloud Shell, create a VM scale set, replacing <RESOURCE_ID> in the image variable with the name you just copied.

Additional Resources

You decide that creating an image of a VM is the best solution because you can capture all the custom software and redeploy the image many times.

In order to create an image, you need to create an image gallery. This allows you to share the image with others and refer to it when deploying into a virtual machine scale set.

Once you've created the image gallery, create an image definition to provide detail about the image like the operating system and software installed.

Next, create an image version that you can refer to when you patch the image (e.g., latest, 1.0, etc.).

Finally, create a virtual machine scale set and refer to the image you just created in the previous steps.

NOTE: In order for the az sig create --resource-group $RG --location westus --gallery-name imageGallery[some unique characters]command to run successfully, make sure to add some characters to the end of the imageGalleryname to make it unique.

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?