hamburger icon close icon
Linux on Azure

Linux on Azure: Optimizing Cost, Performance, and Security

How Can You Use Linux on Azure?

Azure Virtual Machines (VM) are a commonly used resource in Azure, enabling scalable, on-demand computing to users. VMs are a foundation of Azure’s Infrastructure as a Service (IaaS) offering. These machines enable you to create custom environments that can serve as remote desktops, application hosts, or workload processors. One of the benefits of VMs over other Azure resources is that you can specify exactly what OS you want your environment to have.

In Azure, this means you can select from a range of supported Linux distributions. Through the Azure Marketplace, you can currently find machine images for Ubuntu, Debian, SUSE Linux Enterprise, CentOS, CoreOS, and Red Hat Enterprise. Azure is also actively working with a variety of Linux communities to add support for more distributions.

Additionally, you can bring your own Linux image if the distribution you want isn’t currently available in the Marketplace. To do this, you need to create and upload the version as a Linux virtual hard drive (VHD) which you can then attach to your VM.

This is part of an extensive series of guides about managed services.

In this article, you will learn:

When to Use Linux on Azure

When deciding whether to use Linux on Azure, several factors should be considered:

  • Existing development system and platform: If your organization is already using Linux-based systems or has a development team familiar with Linux, moving to Linux on Azure can be a natural transition.
  • Maintenance: Managing and maintaining on-premises hardware and infrastructure can be resource-intensive. Azure's cloud-based infrastructure reduces the maintenance burden by handling hardware updates, security patches, and other tasks, allowing your team to focus on core business activities.
  • Costs: Azure offers a pay-as-you-go pricing model that can provide cost savings compared to traditional on-premises infrastructure. By only paying for the resources you consume, you can optimize costs according to your workload needs.
  • Scalability: Azure provides on-demand scaling, ensuring your Linux-based workloads can grow or shrink according to your business requirements.
  • Support: Microsoft offers extensive support for Linux on Azure, including documentation, community forums, and dedicated customer support.
  • Jointly built solutions for specific use cases: Microsoft collaborates with various Linux vendors to provide tailored solutions for specific use cases, such as SAP on Azure or Red Hat OpenShift on Azure, ensuring seamless integration and optimized performance.
  • Vendor neutrality: Despite being a Microsoft product, Azure acts as a neutral partner, supporting open-source technologies and fostering collaboration with various Linux vendors. This vendor-neutral approach enables businesses to choose the best tools and technologies to meet their needs without being locked into a single ecosystem.

Types of Linux Virtual Machines in Azure

When planning to run Linux in Azure, you need to choose a machine type that fits your workload requirements. There are six categories of VMs to choose from with subtypes or “sizes” of each.




General purpose

Designed to provide a balance of CPU-to-memory. Common uses include low to medium traffic web servers, small to medium databases, and development and testing environments. 

B, Dsv2, Dsv3, Dsv4, Dv2, Dv3, Dv4, Dasv4, Dav4,  DC, DCv2, Ddv4, Ddsv4, Av2

Compute optimized

Designed to prioritize CPU over memory resources. Common uses include application servers, batch processing, network appliances, and medium traffic web servers.


Memory optimized

Designed to prioritize memory over CPU resources. Common uses include in-memory analytics, relational database server, and medium to large caches. 

Esv3, Esv4, Ev3, Ev4, Easv4, Eav4, Edv4, Edsv4, Mv2, M, DSv2, Dv2

Storage optimized

Designed for high IO and disk throughout. Common uses include transactional databasing, data warehouses, and big data. 



Designed for accelerated processing with one or more GPUs. Common uses include training deep learning models, video editing, and heavy graphic rendering. 

NC, NCv2, NCv3, ND, NDv2 (Preview), NV, NVv3, NVv4

High performance compute

Designed to provide high CPU resources and high-throughput networking. Common use cases include big data analytics, predictive models, and data streaming. 

H, HC, HB, HBv2

For more information, you can see details in the official documentation here.

Linux VM Pricing Models

After your machine type is selected, there are three main payment models you can choose from.

Pay as you go
The pay as you go model charges for any compute resources you use by the second. It requires no contracts and is billed after use. You can scale use as needed and on-demand. 

This model is recommended for users who:

  • Want to control cost without giving up flexibility
  • Have high priority applications with variable workloads
  • Want to develop or test applications on VMs

Reserved VM Instances
Reserved instances are VMs that you agree to use for a one or three year period and pay for in advance. In exchange for this commitment, you get a 72% discount over pay as you go pricing. These instances are still somewhat flexible and you can return or exchange instances as needed.

This model is recommended for users who:

  • Have applications with predictable workloads
  • Want or need to budget in advance
  • Have long term workloads or plans

Spot Pricing
Spot pricing is an option that enables you to access surplus capacity from random servers. With this method, your cost is discounted by up to 90% off pay as you go costs but sacrifice reliability. 

The availability of these machines is unpredictable, although there are usually resources available. However, where resources are located changes frequently and your workloads are booted if the host server requests the resources you’re using. 

This model is recommended for users who:

  • Are on a very tight budget
  • Are using low priority applications that can be interrupted without issue
  • Have flexible workloads with no SLA or timeframe

Savings plans for compute
Azure Savings Plans for Compute are a flexible pricing option that offers significant discounts on Azure virtual machines (VMs) and other compute resources. By committing to a consistent level of usage for a 1- or 3-year term, customers can save up to 72% compared to pay-as-you-go rates. 

This model is recommended for users who:

  • Have predictable or steady workloads
  • Are committed to using Azure for a specified period of time (typically one or three years)
  • Want to reduce their compute costs by paying upfront or over a period of time

Creating a Linux Virtual Machine in Azure

An Azure Virtual Machine (VM) is an on-demand, scalable computing resource offered by Microsoft Azure, providing users with a virtualized environment for running applications and services. VMs can be customized with different configurations of CPU, memory, storage, and networking resources to meet specific workload requirements.

There are a few ways to create a Linux-based VM in Azure. VMs can be configured and run via the Azure portal, the Azure CLI, or a template from Azure Resource Manager.

Step 1: Create an Azure VM

To create an Azure VM, sign in to the Azure portal, click Create a resource, search for your desired OS (e.g., Linux, Windows), and click Create. Fill in the required information, configure authentication, and adjust optional settings. Review and click Create to deploy the VM. Alternatively, you can use preconfigured images from Azure Marketplace.

Step 2: Create Resources to Host the Linux VM

To host a Linux VM in Azure, you need to create and configure several resources. Start by creating a resource group, which is a logical container for organizing and managing resources in Azure. This helps maintain a structured and easily manageable environment.

Next, create the VM itself, specifying memory and CPU based on workload requirements. This determines the VM size and performance. For storage, create virtual disks to hold the applications, data, and operating system. These virtual disks are hosted in an Azure Storage account, which needs to be set up as well.

For networking, create a Virtual Network (VNet) to enable communication between your VM and other resources, both within Azure and externally. Additionally, set up a network interface to connect the VM to the VNet.

Optionally, allocate a public IP address to access the VM from the internet. This enables remote management and connectivity to the VM.

Step 3: Select a VM Image

A VM image is a pre-configured template containing an operating system, along with optional pre-installed applications and configurations, used to create a virtual machine. Choosing a VM image is important because it determines the base environment and settings for the VM, including the operating system, software packages, and security configurations.

Selecting the appropriate VM image ensures compatibility with your intended applications and workloads, simplifies the deployment process, and saves time on configuration and setup, enabling a quicker launch of the VM instance.

Step 4: Choose the VM Size

Sizing a VM refers to the process of selecting an appropriate VM size, which determines the amount of CPU, memory, storage, and networking resources allocated to a virtual machine. VM sizes in Azure are grouped into different series, each designed to cater to specific workloads and requirements.

A-series (Basic) and B-series (Burstable) VMs are suitable for entry-level workloads, testing, and development. At the other end of the spectrum, H-series (High-Performance Compute) VMs are tailored for high-performance computing workloads with advanced networking and fast CPUs.

Step 5: Select the Storage Options

Storage decisions are the next options to specify. One key aspect to consider is the disk technology. Azure offers two types of disk storage:

  • HDD: These are magnetic-based storage devices that provide a cost-effective solution for infrequent data access, testing environments, and applications with lower IOPS (input/output operations per second) requirements. HDDs generally have slower read/write speeds compared to SSDs.
  • SSD: These are flash-based storage devices offering higher performance, lower latency, and better durability. They are suitable for mission-critical applications, databases, and workloads requiring high IOPS and low latency. Azure provides different tiers of SSDs, such as Standard SSDs (for cost-effective and consistent performance) and Premium SSDs (for high-performance and mission-critical workloads).

Another choice to make is between managed and unmanaged disks:

  • Managed disks: Azure handles the storage account and underlying infrastructure, providing benefits like automatic scaling, built-in redundancy, and simplified management. They offer better reliability, performance, and security compared to unmanaged disks. Managed disks also support features like snapshots, disk encryption, and integration with Azure Backup.
  • Unmanaged disks: These are legacy storage options where the user is responsible for creating and managing the storage account hosting the VM's virtual disks. This requires more manual configuration and management, but may provide slightly more control over the storage setup.

Step 6: Set Up Network Communication

A VNet (Virtual Network) is a logical isolation of the Azure cloud that enables communication between resources, providing a secure and customizable networking environment. VNets can be divided into subnets, which are smaller network segments within the VNet.

Dividing a VNet into subnets helps manage and organize resources more efficiently, improves network security by isolating resources, and allows for better control over traffic flow and routing between different segments of the network.

Best Practices To Optimize Azure Linux VMs Costs

Optimizing your cloud costs is an essential part of ensuring that cloud resources are budget friendly and maximizing your ROI. Although some workloads do not allow for much flexibility, there are some practices that can help reduce your costs for most use cases. 

Consider B-Series VMs

B-series machines are designed for burst processing and are best used for workloads that are usually idle with occasional activity peaks. These VMs are always available and enable you to work within throughput and IO caps over a given period. This helps reduce your cost by ensuring that you aren’t paying for the maximum amount of capacity at all times. 

Find the Right Resource Size

Right-sizing your VMs helps ensure that you are not paying for excess resources or impeding performance with too few resources. Azure offers tools to help you right-size and you can use metrics available through Azure Portal to gauge your current use. In general, if you are using 50% or less of your allotted resources, it’s safe to downsize.

Azure Spot VMs for Batch Processing

While Spot VMs are not suited for many common uses, these machines are good for interruptible processes, like batch processing. Any workloads that you would typically run in the background of your machines can be considered for these VMs. 

Take Advantage of Azure Hybrid Benefit

Hybrid Benefit is an option that enables you to bring existing SQL and Windows Server licenses to your VMs. Rather than paying for this licensing with your machine costs, you can continue paying down existing technical debt without interrupting your operations. 

Best Practices To Secure and Optimize Azure Linux VMs

In addition to optimizing costs, you should pay attention to maximizing the security and performance of your VMs. Investing in resources without ensuring their functionality or privacy negates any cost savings you might achieve. 

Optimize Networking

Network performance varies by VM size, so you need to ensure that the size you choose provides adequate bandwidth. You might also consider adopting VMs that support Accelerated Networking. This functionality provides low latency and CPU utilization via single-root input/output virtualization (SR-IOV) bypasses. 

Security Center

Azure Security Center is a native service that you can use to evaluate your security posture in Azure. It can identify potential vulnerabilities and recommend fixes to increase your security. You can also use Security Center to monitor your VMs and applications and manage security through policies. 


Although Azure offers durability guarantees, you should still backup your VMs for disaster recovery purposes. You can manually perform these backups or use Azure Backup to script automatic backups during off-hours. 

Linux on Azure with Cloud Volumes ONTAP and Azure NetApp Files

NetApp Cloud Volumes ONTAP, the leading enterprise-grade storage management solution, delivers secure, proven storage management services on AWS, Azure, and Google Cloud. Cloud Volumes ONTAP capacity can scale into the petabytes, and it supports various use cases such as file services, databases, DevOps, or any other enterprise workload, with a strong set of features including high availability, data protection, storage efficiencies, Kubernetes integration, and more.

In particular, Cloud Volumes ONTAP provides centralized storage management, serving NAS, including NFS, SMB / CIFS as well as iSCSI and S3, and multiprotocol access.

Learn more about how Cloud Volumes ONTAP helps to address the challenges of storage management in these Cloud Volumes ONTAP on Azure Customer Case Studies.

Azure NetApp Files is another file storage managed service alternative from Microsoft Azure built on NetApp technology, giving you enterprise file share capabilities that can support even your core business applications.

New call-to-action

Learn More About Linux on Azure

Read more in our series of guides about Linux on Azure

Ready to Solve Your Enterprise Linux File Requirements in Azure?
Azure provides robust support for Linux workloads, provided you familiarize yourself with its capabilities. This means understanding what resources are available to you in Azure and through its partnerships with services like Azure NetApp Files.

This article explains common challenges of using Linux file shares in the cloud, how you can set up files shares easily with Azure NetApp Files, and a few benefits of using Azure NetApp Files.

Read more: Ready to Solve Your Enterprise Linux File Requirements in Azure?

Build Your Own Azure NFS? Wrestling Linux File Shares into Cloud
Deploying Linux file shares in the cloud can present a challenge which may cause organizations to delay migration. This works temporarily but movement to the cloud is inevitable for many organizations and putting it off may end up costing you more.

This article explains what files services are available in Azure, what Azure NetApp Files is and the benefits it provides, and how you can use Azure NetApp Files to move Linux file shares easily.

Read more: Build Your Own Azure NFS? Wrestling Linux File Shares into Cloud

Linux on Azure Workload Migration: Challenges and Solutions
Migrating workloads to the cloud can be time consuming and challenging. While moving data you need to ensure that your production system continues to operate smoothly while ensuring that your new system is ready for a smooth transition.

This article explains some challenges you may face when migrating Linux workloads to Azure, how Azure NetApp Files can make the process easier, and how Azure NetApp Files features support smooth migrations in general.

Read more: Linux on Azure Workload Migration: Challenges and Solutions

Azure NetApp Files Benchmarks
When choosing a solution to support your Linux workloads in Azure, it’s important to understand how it performs. This includes benchmarking throughput and IOPS for scale out and scale up operations.

This article highlights important benchmarks for Linux with Azure NetApp Files.

Read more: Azure NetApp Files Benchmarks

NetApp Predicts: More Than 80% of Azure VMs Will be Linux
Linux workloads are increasingly popular for enterprise workloads and this number is expected to continue climbing. This growth is driving the need for comprehensive support of Linux in all cloud environments, including Azure.

This is a webinar covering how Azure NetApp Files supports Linux in Azure and how you can use it to run Linux workloads in the cloud.

Read more: NetApp Predicts: More Than 80% of Azure VMs Will be Linux

See Additional Guides on Key Managed Services Topics

Together with our content partners, we have authored in-depth guides on several other topics that can also be useful as you explore the world of managed services.

AWS Database

Authored by NetApp

What is Cloud Hosting

Authored by Atlantic

Dedicated Server Hosting

Authored by Atlantic

Cloud Data Services