top of page
Writer's pictureRattandeep singh

Azure VM Licenses: Find Out Fast



How to Check Your Azure VM License Information?

Knowing how your Azure Virtual Machines (VMs) are licensed is crucial for cost management and compliance. This blog post will guide you through two methods to retrieve your Azure VM license details

  • Azure portal

  • Azure PowerShell


Understanding Azure VM Licensing

Before diving in, it's helpful to understand the different Azure VM licensing models:

  • Pay-As-You-Go (PAYG): Licenses are automatically included in the VM pricing.

  • Azure Hybrid Benefit (AHB): You leverage existing on-premises Windows Server licenses for cost savings.

  • Bring Your Own License (BYOL): You provide your own Windows or Linux licenses.


Method 1: Using the Azure Portal

  1. Navigate to your VM: Sign in to the Azure portal and locate the virtual machine you want to check.

  2. Access VM settings: Go to Settings > Operating System.

  3. View License Type: under Licensing, "Yes" = Azure Hybrid Benefit, "No" = Pay-As-You-Go (Azure VM Licensing).


Method 2: Using Azure PowerShell

  1. Connect to Azure PowerShell: Launch Azure Cloud Shell from the portal or use the Azure PowerShell module on your local machine. Ensure you're signed in to the correct Azure subscription.

  2. Run the Get-AzVM cmdlet: Use the following command, replacing <resource-group-name> and <VM-name> with your specific details:

Get-AzVM -ResourceGroup "<resource-group-name>" -Name "<VM-name>"
  1. Examine License Details: The output will display various VM properties, including the LicenseType. This field provides the same information as the Azure portal method.


Additional Considerations

  • For BYOL scenarios, the Azure portal won't show detailed license information. You'll need to manage your licenses externally.

  • For a comprehensive overview of all your VMs' licenses, consider using Azure Resource Graph queries or Azure Cost Management reports.


Following these methods, you can easily retrieve your Azure VM license information and ensure your cloud environment is optimized for cost and compliance.


Bonus: Below is the script to get the license information for all VMs in Azure using PowerShell.
# Store credential to connect with Azure Account use format 
$creds = Get-Credential 

# Connect to selected subscription 
Connect-AzAccount -Credential $creds -Subscription gsk-corp-iam-activedirectory-prod 

# Get details of all VMs in the subscription 
$vms = Get-AzVM   

# Create an array to store VM details 
$vmDetails = @()   

# Extract server name, server size, and licensing type for each VM 
foreach ($vm in $vms) 
	{	
		$serverName = $vm.Name   
		$serverSize = $vm.HardwareProfile.VmSize   		      	
		$licensingType = $vm.LicenseType     

		# Create a hashtable for the VM details   
		$vmDetail = @{
			ServerName = $serverName     
			ServerSize = $serverSize     
			LicensingType = $licensingType   
					}     
		# Add the hashtable to the array   
		$vmDetails += New-Object PSObject -Property $vmDetail 
}   

# Export the VM details to a CSV file 
$vmDetails | Export-Csv -Path "c:\temp\AzureVM_Details.csv" -NoTypeInformation

29 views0 comments

Comments


bottom of page