Introduction

In this guide, I will show you, step by step, how to create your first virtual machine on Microsoft Azure, tailored for both testing environments and production workloads.

I will show you some tricks to use to reduce the VM cost. It’s particularly useful when you use Azure to deploy VM for testing or for your LAB environments.

I’ll share key strategies for minimizing your virtual machine costs. These optimization tactics are especially valuable when running Azure VMs for testing, sandboxes, or lab environments.

Pre-requisites:

Before you start, ensure that you have:

  • A Microsoft account.
  • An active Azure subscription.

How to create a free Azure account?

Microsoft offers a free trial of its popular Azure services for 12 months. On top of that, you will get $200 in credits for your first 30 days.

After you sign into your Microsoft account, you must choose between two types of Azure accounts: Azure free account and Pay-as-you-go account.

The accounts offer nearly the same features and functionality, except that the Azure free account is available only to new Azure customers, who receive a $200 credit valid for 30 days to test paid features.

Important: For both formulas, you need to provide your credit card number when registering. As Microsoft notes, this is used strictly for identity verification to ensure you are a real person and not a bot. Your card will not be charged unless you exhaust your $200 free credit and explicitly choose to upgrade to paid services.

What kind of VM can you use for free:

Not all VMs are available for free when a user signs in as a new Azure customer. There are two Virtual machines avaible for free: B1s, B2pts v2 (Arm-based), and B2ats v2 (AMD-based) burstable VMs, with maximum of 2 vCPUs and 1 GB of RAM

If you want to use a VM with more resources, you can use your $200 Azure free credit, which is valid for your first 30 days..

What happens after the 30 days period expires?

  • Any remaining balance of your $200 credit will expire at the end of the 30 days, even if it hasn’t been fully used.
  • If you sign up for an Azure free account, we’ll notify you that it’s time to decide if you want to move to pay-as-you-go pricing. If you do, you’ll continue to receive free services and be able to purchase services beyond free amounts. If you don’t, your account and services will be disabled. To resume usage, you’ll need to move to pay as you go.

Understanding Azure components

Before creating your first VM, you need to understand the Azure components involved in the VM’s life cycle.

Subscription

When you create your account in Microsoft Azure, whether you choose Free trial or the Pay-as-you-go formula, a subscription container is created. A subscription is considered the highest organizational level in Azure. All resources you will create later on (VM, Network, Storage,…etc.) are attached to that subscription.

It serves as a billing boundary, allowing you to track resource usage and costs. You can also establish budget limits and cost alerts to prevent unexpected charges.

Resource Group

According to the Microsoft definition, a resource group is a container that holds related resources for an Azure solution (e.g., a virtual machine).

You decide how to allocate resources to resource groups based on what makes the most sense for your organization. Generally, add resources sharing the same lifecycle to the same resource group so you can easily deploy, update, and delete them as a group.

For example, suppose you want to create a lab with two Windows servers and one Windows 11 client. In this case, you create a resource group that contains all those VMs. Once you no longer need that lab, you can simply delete the resource group instead of deleting each VM individually.

Steps for VM Creation

1/ Create the Resource Group

  1. Sign in to the Azure portal.
  2. Select Resource group, then click on Create
  1. Select your Azure subscription.
  2. Enter a new resource group name.
  3. Select an Azure location. Region selection affects availability, latency, cost, and regulatory alignment.
  4. Select Review + Create
  5. Select Create. It takes a few seconds to create a resource group.

2/ Create the Virtual Machine

  1. From the Resource group page select the resource group you just created, then click on the Create button.

2. On the marketplace page, select the operating system image you want to deploy on your VM; you can use the search bar to quickly find the OS you want.

  1. Select the resource group.
  2. Give a name to your VM.
  3. Select a region where to create your VM.

Note: A VM’s region can differ from its resource group’s region. This does not affect performance, as the resource group stores only metadata for the VM and its associated resources.

The availability option provides resilience for your VM by deploying it across multiple zones. The default selection is one zone.

Note: Choosing multiple zones will increase the VM’s cost.

Security type refers to the different security features available for a virtual machine. Security features such as Trusted Launch and Confidential VMs help enhance the security of Azure Gen 2 virtual machines.

By default, the “Trusted launch virtual machines” option is selected, which will protect your VM against persistent and advanced attacks, by leveraging feature like secure boot and virtual trusted execution environment (TPM).

  1. Select the image of the OS you want to deploy.
  2. Select the VM size. Pay attention to the VM cost; choose the size that fits your needs and budget.

Click on the “See all sizes” option to list all the available choices.

If you are on a budget or creating VMs for testing a lab environment, Azure lets you reduce VM prices by choosing “Run with Azure Spot Discount“. This will allow your VM to use the unused capacity. The downside is that at any point in time, when Azure needs the capacity back, the Azure infrastructure will evict Azure Spot Virtual Machines.

The eviction rate varies by region; click the “View pricing history and compare prices in nearby regions” option, then check the region’s eviction rate.

  1. Enter the username and the password of the account you want to use to log in into the VM.
  2. Select the protocol you want to use to open a session on the VM; usually RDP for Windows and SSH for Linux.
  3. Click the “Next” button.
  1. Select the OS disk size.
  2. Select the OS disk type; you can choose from Standard SSD, Premium SSD, and disk redundancy.
  3. Click the “Next” button.

To configure the network follow the steps:

  1. Create the virtual network.
  2. Choose the subnet you want to use (eg. 192.168.0.0/24).
  3. Choose the network security group that will contain the security rules that allow or deny the inbound/outbound traffic.
  4. Click the “Review + create” button.

Before confirming the VM creation, review the estimated monthly cost. This section provides both the total projected monthly cost and a detailed breakdown by component, including the VM image, size, disks, networking, and other associated resources.

As a final step click on the create button. The VM creation process will take a few seconds.

Once the VM is created, click the “Go to resource” button to access your VM resources.

How to Access the VM

  • Copy the VM’s public IP address and paste it into the remote desktop app or download the RDP file.,
  • On the logon screen, enter the username and password you created earlier.

How to Stop the VM

There are two ways to stop the VM:

1/ From inside the VM

The VM operating system stops, but Azure still considers the VM allocated, and you continue paying for compute charges.

2/ From Azure Portal

On the VM page, select the VM you want to stop (Deallocate), then click on “Stop” to shut down the VM and release the underlying compute resources.

You will not be charged for the compute resources, but you will continue paying for the OS disk and the reserved public IP address.

Conclusion

At this stage, you can connect to your VM using Remote Desktop and start experimenting with Windows Server in the cloud. However, exposing RDP directly to the Internet is not considered a best practice in production environments.

In the next article, we will explore how to access Azure virtual machines securely without exposing RDP ports to the Internet.

Share this article

Leave a Reply