Using Ephemeral OS Disks in Azure for Stateless VMs

30 minutes
  • 2 Learning Objectives

About this Hands-on Lab

Azure OS Disks serve as the primary storage for Azure Virtual Machines. Persistent disks provide reliability and robust backup guarantees for stateful VMs, but these disks cost money. If your VM is stateless, however, you can use an ephemeral OS disk, which has no additional storage cost beyond the base compute cost of the VM itself. These ephemeral disks can also be deployed and reimaged more quickly than persistent disks. In this lab, you will have the opportunity to experiment with ephemeral OS disks by building and reimaging a stateless VM.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create the stateless VM.
  1. Log in to the Azure Portal.

  2. Click + Add and add a new Ubuntu Server.

  3. Enter ephemeral-disk-poc for the Virtual machine name.

  4. Select Ubuntu Server 18.04 LTS for the Image.

  5. Click Change size, then select DS1_v2 and click Select.

If you want to log in using a password, select Password for Authentication type, then supply a username and password. Be sure you remember the password so you can log in later.

  1. Under Disks, click Advanced. Select Yes for Use ephemeral OS disk.

  2. Click Review + create, then Create.

Wait a few minutes for your VM deployment to finish.

Reimage the VM.
  1. Go the Azure portal. Navigate to your resource group and click on the ephemeral-disk-poc VM. You should see a Public IP Address. Use this, along with the credentials you created earlier, to log in to the VM.

  2. Create some test data in the home directory:

echo "Hello, World!" > test.txt
  1. Verify that the file exists. You should see test.txt listed:
  1. In the Azure portal, navigate to the ephemeral-disk-poc VM.

  2. Click the Reimage button and confirm. Wait a few moments for the reimaging to complete.

If you still have your ssh session open, it will be closed as the VM shuts down. The newly-imaged VM will have a new host key, which may result in an error if you attempt to log in again. You can avoid this by removing the old host key from your known_hosts file.

  1. Replace <public IP of the VM> with the actual public IP of your VM:
ssh-keygen -R <public IP of the VM>
  1. Log in to the vm again. Check for the test.txt file again. This time, the file will not be present, since the VM has been returned to a clean state.

Additional Resources

Your company, Store All the Things!, is using a variety of virtual machines in Azure. Some of these VMs are stateless, meaning that the data on their disks is not important and does not need to be kept. New VMs can quickly and easily replace these VMs at any time.

These stateless VMs are using persistent disks, which results in additional storage costs beyond the compute cost of the VMs themselves. The company would like to convert these VMs to use ephemeral OS Disks, which do not incur any additional storage cost. Your task is to perform a quick proof-of-concept to demonstrate how these ephemeral OS disks can be used. Create a new Virtual Machine that uses an ephemeral OS disk, then reimage that machine's disk to demonstrate how these VMs can be quickly and easily built and reimaged.

Some additional details:

  • Give the Virtual Machine the name ephemeral-disk-poc
  • Use a size of DS1_v2
  • Use the Ubuntu Server 18.04 LTS image

If you get stuck, feel free to check out the solution video, or the detailed instructions under each objective. Good luck!

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?