top of page

Azure VM license management

  • Writer: Sanjiv Sidhar
    Sanjiv Sidhar
  • Jul 26, 2024
  • 2 min read

It is good practice to perform regular inventories of your Azure Subscriptions to keep track of your virtual machines and their configurations, usage, and maintain compliance with licensing standards.


The primary Azure VM license types are:

Pay-As-You-Go Licensing (PAYG):

Windows Server: the cost of the Windows operating system license is included in the VM's hourly rate.

Linux: Many Linux distributions are available under pay-as-you-go pricing, with the operating system cost included in the VM pricing.


Bring Your Own License (BYOL):

Windows Server: If you already own Windows Server licenses with Software Assurance, you can use the Azure Hybrid Benefit (AHB) to apply these licenses to your Azure VMs. This can significantly reduce the cost of running Windows VMs in Azure.

SQL Server: Similar to Windows Server, SQL Server licenses with Software Assurance can be applied to Azure VMs, reducing the cost of running SQL Server workloads.

Linux: Some Linux distributions support BYOL, allowing you to use your existing licenses for certain enterprise Linux versions.


Azure Hybrid Benefit:

  • This benefit allows you to use your on-premises Windows Server and SQL Server licenses with Software Assurance to get a discount on Azure services so you only pay for the base compute rate of the VM.


To check Azure VM License type on a subscription using PowerShell


  1. Login to the Azure Portal

  2. Run the Azure Cloud shell PowerShell console

  3. Switch to the target Azure Subscription

set-azcontext -Subscription <subscription-id>

4. Retrive a list of all VMs in the subscription, and their license type and output in a table format

Get-AzVM | Format-Table -Property ResourceGroupName, Name, Location, LicenseType

The license types returned will be one of the following values:

  • Windows_Server: The VM is licensed using Azure Hybrid Benefit for Windows Server.

  • Windows_Client: The VM is licensed using Azure Hybrid Benefit for Windows Client.

  • RHEL_BYOS: The VM is licensed using Bring Your Own Subscription for Red Hat Enterprise Linux.

  • SLES_BYOS: The VM is licensed using Bring Your Own Subscription for SUSE Linux Enterprise Server.

  • null or empty: The VM is licensed using pay-as-you-go licensing for its operating system.


To change the license type of a VM, named VMName, then the following code can be run :


$vm = Get-AzVM -ResourceGroupName <ResourceGroupName> -Name <VMName>
$vm.LicenseType = "Windows_Server"
Update-AzVM -ResourceGroupName <ResourceGroupName> -VM $vm

The Microsoft Azure bill provides details of the number of VMs with AHB running. Regular OS license checks on Azure VMs allows identification of opportunities to save costs by applying AHB or preventing over-payment of unnecessary PAYG licenses. It also allows identification of unused licenses helping to further optimize spending.


Sanjiv Sidhar

  • LinkedIn
bottom of page