There are many reasons to create a Linux Virtual Machine (VM) in Azure; like hosting a web server, database, or many other uses for VMs. It’s extremely easy to create a Linux VM in Azure, in fact you can do it in a matter of a few minute. Then once created, the VM can be connected to via SSH enabling you to configure it for what ever workload you need.

Azure Virtual Machines are the compute capability in Microsoft Azure that enables you to create and host servers in the cloud. This enables an on-demand, scalable cloud-computing resource that just works without worrying about any of the hardware underneath. You are only billed when the VM is running, and you can stop and deallocate the VM if you need to shut it down to suspend billing, and then you can start it back up again to get it running again for use. This makes Azure VMs perfect for everything from continuously running VM workloads (aka “always running”) like you would use for servers, or even remote terminals or task specific VMs that you only need periodically from time to time.

Next, let’s look at creating a Linux VM in Azure so you can get started configuring your workload to run in the cloud!

Create a Linux VM in Azure

There are several Linux distributions made available within Microsoft Azure through the Azure Marketplace. These include Ubuntu, CentOS, RedHat Enterprise Linux (RHEL), and more! For the following steps, we’ll use Ubuntu Server, but go ahead and choose the distro you prefer as you follow along. Let’s go!

  1. Within the Azure Portal (, click on the + Create a resource button at the top of the Home page.
    Create Linux VM in Microsoft Azure 1
  2. On the Create a resource page, search the Azure Marketplace for your favorite Linux distro, then select it. For this article, we’ll search and pick Ubuntu Server.
    Create Linux VM in Microsoft Azure 2
  3. On the Azure Marketplace information page for the Linux distro you’ve chosen, click the Create button to get started defining the configuration of the VM to create.
    Create Linux VM in Microsoft Azure 3
  4. On the Create a virtual machine page, you will see the Basics tab, and you’ll need to fill out all the required configurations for this new Linux VM. To start, select your Azure Subscription and an existing (or specify to Create new) a Resource group.
    Create Linux VM in Microsoft Azure 4
    The Resource group will be used to organize the multiple Azure resources that are provisioned when the Linux VM is created. You will see later there are several resources created, and using a dedicated Resource group for this VM will keep things well organized in your Azure Subscription.
  5. For the Instance details section, fill out the specifics that are required for the Linux VM you’re creating. This will include the Virtual machine name that defines the name of the Azure Virtual Machine resource, as well as the Size to specify the vCPU and Memory resources for the VM. The rest of the fields you could leave as the default values to move forward with creation.

    Here’s the values that I filled out for these required fields:
    Virtual machine name: b59-linux-vm
    Region: (US) East US 2
    Size: Standard_D4s_v5
    Create Linux VM in Microsoft Azure 5
  6. For the Administrator account section, fill in the Authentication type that you are going to authenticate with as the admin / root user of the Linux VM once it’s created. For simplicity, I’ll choose Password and enter a Username / password to use.
    Create Linux VM in Microsoft Azure 6
    The SSH public key option for Authentication type is much more secure. For any Production VMs, you’ll want to generate an SSH key pair and use that to setup authentication for the Linux VM. For the simplicity of this article I decided to use Password for now.
  7. For the Inbound port rules section, ensure that the Select inbound ports setting is set to SSH (22). This will enable inbound traffic to Port 22 (for SSH) to be allowed on the firewall rules of the Azure Network Security Group that’s configured for the VM once created.
    Create Linux VM in Microsoft Azure 7
    Keep in mind that enabling SSH connections to Port 22 on the Internet is generally a bad idea from a security standpoint. For Production VMs, you’ll want to secure them better than this. But, for this article (and for simple VM usage) this will work for now.
  8. Finally, we’re ready to click the Review + create button at the bottom of the Create a virtual machine page. This will display a review summary of what you’e going to create, and a green “Validation passed” message will show if there are no errors in the configurations chosen. Then click the Create button to tell Azure to actually go create the Linux VM.
    Create Linux VM in Microsoft Azure 8
  9. The deployment of creating the Linux VM in Azure will take a few minutes to complete. While you wait, the portal will display the Deployment progress.
    Create Linux VM in Microsoft Azure 9
  10. Once deployment and provisioning has completed, you will see a message saying “Your deployment is complete”, then click Go to resource to navigate to the newly created VM.
    Create Linux VM in Microsoft Azure 10
  11. Now that you’ve navigated to the newly created Linux VM on Microsoft Azure, you can view the Public IP address for the VM, then use that IP Address to connect to this VM using SSH. And, if you want to Stop / Deallocate the VM to suspend billing when you don’t need it running, the Stop button is right there too!
    Create Linux VM in Microsoft Azure 11

Now you have a Linux VM on Azure that you can use for anything you need!

More Advanced VM Configurations and Security

The previous steps guided you through creating a Linux VM on Microsoft Azure using many of the “default” configurations, including the “default” settings for security. When creating Virtual Machines (VMs) in Microsoft Azure for Production use, you’ll definitely want to configure security better so the VM doesn’t get hacked.

To more properly secure Azure Virtual Machines, you’ll want to use one or more of the following features:

  • Azure Network Security Group (NSGs) can be used to configure the inbound and outbound firewalls for VMs. You can use this to disable Internet access to SSH (port 22) for the Linux VM so it’s only accessible from the local Virtual Network (VNet), or even so it only allows your specific IP Address to connect.
  • Azure Bastion can be used to enable SSH (port 22) access to the Linux VM in Azure right from within the Azure Portal. This is another service to provision and configure, but combining this with NSGs you can secure the VM so it’s not accessible with SSH (or any other port) directly from the Internet.

There are a many other security features in Microsoft Azure, these are just the two most straight forward features to keep in mind. What ever you do, please properly secure your Azure VMs so you don’t get hacked.

Microsoft MVP

Chris Pietschmann is a Microsoft MVP (Azure & IoT) and HashiCorp Ambassador (2021) with 20+ years of experience designing and building Cloud & Enterprise systems. He has worked with companies of all sizes from startups to Fortune 100. He is also a Microsoft Certified Azure Solutions Architect and developer, a Microsoft Certified Trainer (MCT), and Cloud Advocate. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.
HashiCorp Ambassador (2021) Microsoft Certified Trainer (MCT) Microsoft Certified: Azure Solutions Architect