Nordlicht Reisen GmbH, a fictional travel agency, needs a machine with a lot of memory for an analysis on short notice, but only for one afternoon. You are to create a virtual machine (VM), switch to a larger size later, and then make sure it costs nothing anymore. Those are the two exam skills: create a virtual machine and manage VM sizes.
Prior knowledge. What IaaS is and why a VM is called "infrastructure as a service" is explained in "AZ-900 compact", lesson 2.3. How Azure organizes resource groups, regions and cost you know from K3, lessons 3.1.1 to 3.1.3. This lesson is about operating: What do you choose at creation, and what costs money when.
Creating a virtual machine
What is decided at creation
A VM is never alone. At creation, these are created or chosen: the machine itself, an operating system disk, a network interface in a virtual network, usually a public IP address and a network security group. The most important settings on the Basics tab of the portal, according to Microsoft's guides:
| Setting | Meaning |
|---|---|
| Subscription, Resource group | where the resource lives and is billed |
| Virtual machine name | name of the VM; the portal derives the names of the other resources from it |
| Region | location of the machine |
| Availability options | whether and how the machine is spread for resilience (lesson 3.5) |
| Security type | type of security; Microsoft names the value Standard in its guides |
| Image | the operating system image, for example Windows Server 2022 Datacenter: Azure Edition or Ubuntu Server |
| Size | the VM size (CPU, memory; see below) |
| Authentication type, Username, Password or SSH key | how the administrator signs in |
| Public inbound ports | which ports are open from the internet |
More tabs: Disks (lesson 3.4), Networking (module 4), Management (for example auto-shutdown), Monitoring, Advanced, Tags, then Review + create.
Two rules from Microsoft's guides: The password for Windows must be at least 12 characters long and meet the complexity rules. And you should choose the inbound ports (inbound port rules) deliberately: In guides where the machine doesn't have to be reachable from the internet, Microsoft shows the value None for Public inbound ports. Anyone who leaves RDP (3389) or SSH open makes the machine visible to the internet. Better ways (Azure Bastion, private endpoints) are shown in lesson 4.4.
Portal
- Search the portal for Virtual machines (if your portal is set to another language, look for the same item under its translated name; the search box finds both) and, under Services, choose Virtual machines.
- Choose Create and then Azure virtual machine (some guides say Virtual machine).
- Fill in the Basics tab: resource group, name, region, image, size, administrator account, inbound ports.
- On the Management tab you find Enable auto-shutdown; Microsoft's guide names it as an option to shut the machine down at a fixed time.
- Choose Review + create, wait for the validation and choose Create.
Azure CLI
Microsoft's quickstart for a Linux machine:
az group create --name <ressourcengruppe> --location <region>
az vm create \
--resource-group <ressourcengruppe> \
--name <vm-name> \
--image Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts-gen2:latest \
--admin-username azureuser \
--generate-ssh-keys \
--public-ip-sku Standard
The parameter --generate-ssh-keys looks for an SSH key in ~/.ssh and creates one if there is none. --image takes the four parts publisher, offer, SKU and version here (latest is the newest version). For a Windows machine, Microsoft names in examples the publisher MicrosoftWindowsServer, the offer WindowsServer and the SKU 2022-datacenter-azure-edition; instead of an SSH key you give --admin-username and --admin-password. With --size you choose the size; without it, the command takes a default value that you can look up in the reference for az vm create. In Azure PowerShell, New-AzVM is the matching command; you find its parameters in the reference.
Note: Besides the machine, the command creates a public IP address and other resources. Everything lives in the resource group; that is why you clean up through the group.
You see the state and the addresses with:
az vm show --show-details --resource-group <ressourcengruppe> --name <vm-name> --query powerState --output tsv