Lab: create a virtual machine, then delete everything
Video chapters
- 0:00 Introduction
- 0:07 Resource group
- 0:33 Virtual machine
- 1:23 Verification
- 1:39 Cleanup
A small web agency wants to test an application on a Linux server before showing it to a client. Buying a machine would take a week. In Azure, it has one in a few minutes, and it stops paying the moment it deletes it. The only risk is forgetting to delete it: a VM that runs for a month doing nothing shows up on the bill.
In this lab, you put a virtual machine in a resource group, look at everything Azure created around it, then delete the group to wipe it all out in a single operation.
Duration: about 25 minutes, including 5 minutes of waiting during deployment. Prerequisites: an Azure account. The free trial is enough.
The screenshots show the portal in English, and the labels below match them.
Cost and cleanup The VM size used here (Standard_D2s_v3) shows at around $70 per month in the portal estimate, or roughly ten cents per hour. On a trial account, it comes out of the free credit. The cost comes mostly from the time the VM runs: do the lab in one sitting and delete the resource group as soon as you finish (step 6). If the size is not available in your region, pick another size with 2 vCPUs.
Step 1: create the resource group
A resource group is a logical folder. Everything you put in it shares the same lifecycle: when you delete the folder, its contents go with it.
- In the portal search bar, type
Resource groupsand open the service. - Click Create.

- Fill in the fields:
| Field | Value |
|---|---|
| Subscription | your subscription |
| Resource group name | IntroAzureRG |
| Region | East US, or the region closest to you |
- Click Review + create, then Create.

What you should see: a "Resource group created" notification, and IntroAzureRG in the list.

Step 2: start the VM creation wizard
- In the search bar, type
Virtual machinesand open the service. - Click Create, then Azure virtual machine.

Step 3: set the Basics tab
On the Basics tab, fill in:
| Field | Value |
|---|---|
| Resource group | IntroAzureRG |
| Virtual machine name | my-VM |
| Region | the same as the group |
| Availability options | no infrastructure redundancy required |
| Image | Ubuntu Server (the LTS version offered by default) |
| Run with Azure Spot discount | unchecked |
| Size | Standard_D2s_v3 |


A Spot VM costs far less, but Azure can take it back without warning when it needs the capacity. For a short test, that would be acceptable. Here we leave it unchecked to get a standard VM.
Further down, under Administrator account:
| Field | Value |
|---|---|
| Authentication type | Password |
| Username | azureuser |
| Password | a password of your own, at least 12 characters, that you do not reuse anywhere |
Under Inbound port rules, choose None for public ports. Nobody will be able to reach the VM from the Internet, which is enough for this lab: you are not going to connect to it.

Step 4: check the price, then create
- Leave the other tabs (Disks, Networking, Management, Monitoring) at their default values.
- Click Review + create.
- Wait for validation to pass, then read the Price block: it is the hourly rate for the size you chose.

- Click Create.
Deployment takes a few minutes. The portal shows a progress page, and there is nothing for you to do.
What you should see: the message "Your deployment is complete".

Step 5: look at the contents of the group
- Open Resource groups, then
IntroAzureRG. - Look at the Resources tab of the overview.
What you should see: six resources, even though you only asked for a VM.

| Resource | Role |
|---|---|
| Virtual machine | compute: processors and memory |
| Disk | the operating system disk |
| Network interface | the VM's network card |
| Virtual network | the private network the VM is plugged into |
| Network security group | the firewall, here with no inbound rule open |
| Public IP address | the address reachable from the Internet |
The wizard created them for you. That is why a test VM goes in its own group: these side resources stay billable (the disk and the public IP above all), even with the VM stopped. Deleting the VM alone would leave them behind.
Step 6: delete the resource group
- In
IntroAzureRG, click Delete resource group. - Type the name
IntroAzureRGin the confirmation field. - Click Delete, then confirm.

What you should see: a "Deleting resource group" notification. A few minutes later, the group is gone from the list, along with the six resources.

If the deletion fails, look for a lock on the group (you will see one in lab 08): it has to be removed first.
What to remember for the exam
- A resource belongs to only one resource group at a time. It can move to another group, but it cannot be in two.
- Deleting a group deletes everything it contains. It is the clean way to tear down a test environment.
- A VM is an IaaS service: Azure manages the hardware, you manage the operating system, its updates, and whatever runs on it.
- A VM stopped from the portal (deallocated) no longer bills for compute, but its disk and its public IP keep costing money.
- The resource group has a region, which is only used to store its metadata. The resources it contains can be in other regions.
Questions and discussion
No messages yet. Have a question about this lesson? Ask it here.
Sign in to join the discussion. Sign in