Azure Hybrid Use Benefit for Windows Server

For customers using Windows Server with Software Assurance, you can bring your on-premises Windows Server licenses to Azure and run Windows Server VMs in Azure at a reduced cost. The Azure Hybrid Use Benefit allows you to run Windows Server virtual machines (VMs) in Azure and only get billed for the base compute rate. For more information, please see the Azure Hybrid Use Benefit licensing page. This article explains how to deploy Windows Server VMs in Azure to use this licensing benefit.

Ways to use Azure Hybrid Use Benefit

There are a couple of different ways to deploy Windows VMs with the Azure Hybrid Use Benefit:

  1. If you have an Enterprise Agreement subscription, you can deploy VMs from specific Marketplace images that are pre-configured with Azure Hybrid Use Benefit.
  2. Without an Enterprise Agreement, you upload a custom VM and deploy using a Resource Manager template or Azure PowerShell.

Deploy a VM using the Azure Marketplace

For customers with Enterprise Agreement subscriptions, images are available in the Marketplace pre-configured with Azure Hybrid Use Benefit. These images can be deployed directly from the Azure portal, Resource Manager templates, or Azure PowerShell, for example. Images in the Marketplace are noted by the [HUB] name as follows:

Azure Hybrid Use Benefit images in Azure Marketplace

You can deploy these images directly from the Azure portal. For use in Resource Manager templates and with Azure PowerShell, view the list of images as follows:

Get-AzureRMVMImageSku -Location "West US" -Publisher "MicrosoftWindowsServer" `
    -Offer "WindowsServer-HUB"

If you don't have an Enterprise Agreement subscription, continue reading for instructions on how to upload a custom VM and deploy with Azure Hybrid Use Benefit.

Upload a Windows Server VHD

To deploy a Windows Server VM in Azure, you first need to create a VHD that contains your base Windows Server build. This VHD must be appropriately prepared via Sysprep before you upload it to Azure. You can read more about the VHD requirements and Sysprep process and Sysprep Support for Server Roles. Back up the VM before running Sysprep.

Make sure you have installed and configured the latest Azure PowerShell. Once you have prepared your VHD, upload the VHD to your Azure Storage account using the Add-AzureRmVhd cmdlet as follows:

Add-AzureRmVhd -ResourceGroupName "myResourceGroup" -LocalFilePath "C:\Path\To\myvhd.vhd" `
    -Destination ""

Microsoft SQL Server, SharePoint Server, and Dynamics can also utilize your Software Assurance licensing. You still need to prepare the Windows Server image by installing your application components and providing license keys accordingly, then uploading the disk image to Azure. Review the appropriate documentation for running Sysprep with your application, such as Considerations for Installing SQL Server using Sysprep or Build a SharePoint Server 2016 Reference Image (Sysprep).

You can also read more about uploading the VHD to Azure process

Deploy an uploaded VM via Resource Manager

Within your Resource Manager templates, an additional parameter for licenseType can be specified. You can read more about authoring Azure Resource Manager templates. Once you have your VHD uploaded to Azure, edit you Resource Manager template to include the license type as part of the compute provider and deploy your template as normal:

"properties": {  
   "licenseType": "Windows_Server",
   "hardwareProfile": {
        "vmSize": "[variables('vmSize')]"

Deploy an uploaded VM via PowerShell quickstart

When deploying your Windows Server VM via PowerShell, you have an additional parameter for -LicenseType. Once you have your VHD uploaded to Azure, you create a VM using New-AzureRmVM and specify the licensing type as follows:

New-AzureRmVM -ResourceGroupName "myResourceGroup" -Location "West US" -VM $vm -LicenseType "Windows_Server"

You can read a more detailed walkthrough on deploying a VM in Azure via PowerShell below, or read a more descriptive guide on the different steps to create a Windows VM using Resource Manager and PowerShell.

Verify your VM is utilizing the licensing benefit

Once you have deployed your VM through either the PowerShell or Resource Manager deployment method, verify the license type with Get-AzureRmVM as follows:

Get-AzureRmVM -ResourceGroup "myResourceGroup" -Name "myVM"

The output is similar to the following example:

Type                     : Microsoft.Compute/virtualMachines
Location                 : westus
LicenseType              : Windows_Server

This output contrasts with the following VM deployed without Azure Hybrid Use Benefit licensing, such as a VM deployed straight from the Azure Gallery:

Type                     : Microsoft.Compute/virtualMachines
Location                 : westus
LicenseType              :

Detailed PowerShell deployment walkthrough

The following detailed PowerShell steps show a full deployment of a VM. You can read more context as to the actual cmdlets and different components being created in Create a Windows VM using Resource Manager and PowerShell. You step through creating your resource group, storage account, and virtual networking, then define your VM and finally create your VM.

First, securely obtain credentials, set a location, and resource group name:

$cred = Get-Credential
$location = "West US"
$resourceGroupName = "myResourceGroup"

Create a public IP:

$publicIPName = "myPublicIP"
$publicIP = New-AzureRmPublicIpAddress -Name $publicIPName -ResourceGroupName $resourceGroupName `
    -Location $location -AllocationMethod "Dynamic"

Define your subnet, NIC, and VNET:

$subnetName = "mySubnet"
$nicName = "myNIC"
$vnetName = "myVnet"
$subnetconfig = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix
$vnet = New-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $resourceGroupName -Location $location `
    -AddressPrefix -Subnet $subnetconfig
$nic = New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $resourceGroupName -Location $location `
    -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $publicIP.Id

Name your VM and create a VM config:

$vmName = "myVM"
$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize "Standard_A1"

Define your OS:

$computerName = "myVM"
$vm = Set-AzureRmVMOperatingSystem -VM $vmConfig -Windows -ComputerName $computerName -Credential $cred `
    -ProvisionVMAgent -EnableAutoUpdate

Add your NIC to the VM:

$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id

Define the storage account to use:

$storageAcc = Get-AzureRmStorageAccount -ResourceGroupName $resourceGroupName -AccountName mystorageaccount

Upload your VHD, suitably prepared, and attach to your VM for use:

$osDiskName = "licensing.vhd"
$osDiskUri = '{0}vhds/{1}{2}.vhd' -f $storageAcc.PrimaryEndpoints.Blob.ToString(), $vmName.ToLower(), $osDiskName
$urlOfUploadedImageVhd = ""
$vm = Set-AzureRmVMOSDisk -VM $vm -Name $osDiskName -VhdUri $osDiskUri -CreateOption FromImage `
    -SourceImageUri $urlOfUploadedImageVhd -Windows

Finally, create your VM and define the licensing type to utilize Azure Hybrid Use Benefit:

New-AzureRmVM -ResourceGroupName $resourceGroupName -Location $location -VM $vm -LicenseType "Windows_Server"

Next steps

Read more about Azure Hybrid Use Benefit licensing.

Learn more about using Resource Manager templates.