Microsoft Azure provides a powerful and flexible cloud computing platform that allows users to build, deploy, and manage various types of applications and services. One of the key services offered by Azure is Azure Virtual Machines, which enables users to deploy and run virtual machines in the cloud. In this tutorial, we will walk you through the process of creating a virtual machine using Azure Virtual Machines, step by step.
Prerequisites
Before we begin, please ensure that you have the following prerequisites in place:
- An active Azure subscription. If you don’t have one, you can sign up for a free trial here.
-
A basic understanding of Azure concepts and terminologies, such as resource groups, virtual networks, and storage accounts. If you’re new to Azure, you can refer to the Azure documentation for more information.
-
A Windows, Mac, or Linux machine with an internet connection.
Step 1: Sign in to the Azure portal
-
Open a web browser and navigate to the Azure portal.
-
Sign in to your Azure account using your credentials.
Step 2: Create a resource group
A resource group is a logical container that holds related resources for an Azure solution. By creating a resource group, you can manage and organize your resources in a more convenient way. Let’s create a resource group for our virtual machine.
- In the Azure portal, click on the “Resource groups” icon in the left-hand menu.
-
Click on the “Add” button to create a new resource group.
-
In the “Basics” tab, provide a name for your resource group. Make sure to choose a meaningful name that reflects the purpose of your virtual machine.
-
Select a subscription from the dropdown list.
-
Choose an appropriate region for your resource group. The region determines the physical location where your virtual machine will be deployed.
-
Click on the “Review + create” button to review your resource group settings.
-
Finally, click on the “Create” button to create the resource group.
Step 3: Create a virtual network
A virtual network (VNet) is an isolated network environment within Azure where you can deploy and run your virtual machines. By creating a virtual network, you can control network traffic, IP addresses, and subnets for your virtual machines. Let’s create a virtual network for our virtual machine.
- In the Azure portal, click on the “Create a resource” button (+) in the left-hand menu.
-
Search for “Virtual network” in the search bar and select the “Virtual network” option.
-
In the “Basics” tab, provide a name for your virtual network.
-
Select the appropriate subscription and resource group that you created in the previous steps.
-
Choose an appropriate region for your virtual network.
-
Select the “IPv4” option for the address space and provide a valid CIDR notation (e.g., 10.0.0.0/16).
-
Click on the “Next: Subnets” button to proceed to the next step.
-
In the “Subnets” tab, provide a name for your subnet.
-
Specify a valid CIDR notation for the subnet address range (e.g., 10.0.0.0/24). Ensure that the subnet address range is within the address space range specified earlier.
-
Click on the “Next: Security” button to proceed to the next step.
-
Review the settings in the “Security” tab and click on the “Next: Tags” button to proceed.
-
Add any applicable tags to your virtual network if desired and click on the “Next: Review + create” button.
-
Finally, review your virtual network settings and click on the “Create” button to create the virtual network.
Step 4: Create a storage account
Azure Storage is a cloud-based storage solution that provides secure, scalable, and highly available storage for your applications and services. To store the virtual machine’s disk and image files, we need to create a storage account. Let’s create a storage account for our virtual machine.
- In the Azure portal, click on the “Create a resource” button (+) in the left-hand menu.
-
Search for “Storage account” in the search bar and select the “Storage account” option.
-
In the “Basics” tab, provide a name for your storage account.
-
Select the appropriate subscription and resource group that you created earlier.
-
Choose an appropriate region for your storage account.
-
Select the “Standard” performance option.
-
Select the “LRS” (Locally Redundant Storage) replication option for redundancy.
-
Click on the “Review + create” button to review your storage account settings.
-
Finally, click on the “Create” button to create the storage account.
Step 5: Create a virtual machine
Now that we have set up a resource group, virtual network, and storage account, we are ready to create our virtual machine. Let’s create a Windows virtual machine using an Azure Marketplace image.
- In the Azure portal, click on the “Create a resource” button (+) in the left-hand menu.
-
Search for “Windows Server” in the search bar and select the “Windows Server” option from the Azure Marketplace.
-
In the “Basics” tab, select the appropriate subscription and resource group.
-
Provide a name for your virtual machine. This is the name that will be used to identify the virtual machine.
-
Select the appropriate region for the virtual machine.
-
Choose the “Image” option for the operating system.
-
Select an appropriate Windows Server version from the dropdown list. We recommend choosing the latest version available.
-
Choose an appropriate size for your virtual machine. The size determines the number of CPU cores, memory, and storage capacity allocated to the virtual machine.
-
In the “Administrator account” section, provide a username and password for the virtual machine’s administrator account. Remember these credentials as you will need them to log in to the virtual machine later.
-
In the “Inbound port rules” section, select the “Allow selected ports” option.
-
Select the appropriate port(s) that you want to open for inbound traffic to your virtual machine. By default, port 3389 (Remote Desktop Protocol) is selected, which allows you to access the virtual machine using Remote Desktop.
-
Click on the “Next: Disks” button to proceed to the next step.
-
In the “Disks” tab, select the storage account and disk type for the virtual machine’s operating system disk.
-
Specify the disk size in gigabytes. We recommend choosing a size based on your requirements.
-
Optionally, you can add additional data disks to your virtual machine by clicking on the “Add data disk” button.
-
Click on the “Next: Networking” button to proceed to the next step.
-
In the “Networking” tab, select the virtual network and subnet that you created earlier.
-
By default, the virtual machine will be assigned a dynamic IP address. If you want to assign a static IP address, select the “Static” option and specify an IP address from the subnet’s address range.
-
Review the other networking settings and click on the “Next: Management” button to proceed.
-
In the “Management” tab, review the settings for monitoring, diagnostics, and backups. You can enable or disable these features based on your requirements.
-
Click on the “Next: Advanced” button to proceed to the next step.
-
In the “Advanced” tab, review the advanced settings such as boot diagnostics, extensions, and Azure Spot instance.
-
Click on the “Next: Tags” button to proceed to the next step.
-
Add any applicable tags to your virtual machine if desired and click on the “Next: Review + create” button.
-
Finally, review your virtual machine settings and click on the “Create” button to create the virtual machine.
Step 6: Connect to the virtual machine
Once your virtual machine is created, you can connect to it using Remote Desktop Protocol (RDP). Follow these steps to connect to your virtual machine:
- In the Azure portal, navigate to the resource group that contains your virtual machine.
-
Click on the virtual machine from the resource list.
-
In the virtual machine’s Overview page, click on the “Connect” button.
-
In the “Connect to virtual machine” blade, click on the “Download RDP file” button to download the Remote Desktop Connection file.
-
Open the downloaded RDP file and enter the username and password that you provided during virtual machine creation.
-
Click on the “Connect” button to establish a remote desktop connection to your virtual machine.
Conclusion
In this tutorial, we have walked you through the process of creating a virtual machine using Azure Virtual Machines. We covered the steps of creating a resource group, virtual network, storage account, and virtual machine. By following these steps, you can deploy a virtual machine in Azure and start running your applications and services in the cloud. Azure Virtual Machines provides a scalable and flexible infrastructure solution that allows you to meet your computing needs effectively.