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.
Successfully complete this lab by achieving the following learning objectives:
- Create the stateless VM.
Log in to the Azure Portal.
Click + Add and add a new
ephemeral-disk-pocfor the Virtual machine name.
Ubuntu Server 18.04 LTSfor the Image.
Click Change size, then select
DS1_v2and click Select.
If you want to log in using a password, select
Passwordfor Authentication type, then supply a username and password. Be sure you remember the password so you can log in later.
Disks, click Advanced. Select Yes for
Use ephemeral OS disk.
Click Review + create, then Create.
Wait a few minutes for your VM deployment to finish.
- Reimage the VM.
Go the Azure portal. Navigate to your resource group and click on the
ephemeral-disk-pocVM. You should see a
Public IP Address. Use this, along with the credentials you created earlier, to log in to the VM.
Create some test data in the home directory:
echo "Hello, World!" > test.txt
- Verify that the file exists. You should see
In the Azure portal, navigate to the
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
<public IP of the VM>with the actual public IP of your VM:
ssh-keygen -R <public IP of the VM>
- Log in to the vm again. Check for the
test.txtfile again. This time, the file will not be present, since the VM has been returned to a clean state.