Azure Hybrid Use Benefit for Windows Server and Windows Client

For customers with Software Assurance, Azure Hybrid Use Benefit allows you to use your on-premises Windows Server and Windows Client licenses and run Windows virtual machines in Azure at a reduced cost. Azure Hybrid Use Benefit for Windows Server includes Windows Server 2008R2, Windows Server 2012, Windows Server 2012R2, and Windows Server 2016. Azure Hybrid Use Benefit for Windows Client includes Windows 10. For more information, please see the Azure Hybrid Use Benefit licensing page.

Important

Azure Hybrid Use Benefits for Windows Client is currently in Preview using the Windows 10 image in the Azure Marketplace. Only Enterprise customers with Windows 10 Enterprise E3/E5 per user or Windows VDA per user (User Subscription Licenses or Add-on User Subscription Licenses) (“Qualifying Licenses”) are eligible.

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. You can deploy VMs from specific Marketplace images that are pre-configured with Azure Hybrid Use Benefit - Windows Server 2016, Windows Server 2012R2, Windows Server 2012 and Windows Server 2008SP1.
  2. You can upload a custom VM and deploy using a Resource Manager template or Azure PowerShell.

Deploy a VM using the Azure Marketplace

Following images are available in the Marketplace pre-configured with Azure Hybrid Use Benefit: Windows Server 2016, Windows Server 2012R2, Windows Server 2012 and Windows Server 2008SP1. These images can be deployed directly from the Azure portal, Resource Manager templates, or Azure PowerShell.

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:

For Windows Server:

Get-AzureRmVMImagesku -Location westus -PublisherName MicrosoftWindowsServer -Offer WindowsServer
  • 2016-Datacenter version 2016.127.20170406 or above

  • 2012-R2-Datacenter version 4.127.20170406 or above

  • 2012-Datacenter version 3.127.20170406 or above

  • 2008-R2-SP1 version 2.127.20170406 or above

For Windows Client:

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

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 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 "https://mystorageaccount.blob.core.windows.net/vhds/myvhd.vhd"
Note

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 a VM via Resource Manager Template

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:

For Windows Server:

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

For Windows Client to use with Azure Marketplace Image only:

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

Deploy a 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:

For Windows Server:

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

For Windows Client to use with Azure Marketplace Image only:

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

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 for Windows Server:

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 10.0.0.0/8
$vnet = New-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $resourceGroupName -Location $location `
    -AddressPrefix 10.0.0.0/8 -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 = "https://mystorageaccount.blob.core.windows.net/vhd/myvhd.vhd"
$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:

For Windows Server:

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

Deploy a virtual machine scale set via Resource Manager template

Within your VMSS Resource Manager templates, an additional parameter for licenseType must be specified. You can read more about authoring Azure Resource Manager templates. Edit your Resource Manager template to include the licenseType property as part of the scale set’s virtualMachineProfile and deploy your template as normal - see example below using 2016 Windows Server image:

"virtualMachineProfile": {
    "storageProfile": {
        "osDisk": {
            "createOption": "FromImage"
        },
        "imageReference": {
            "publisher": "MicrosoftWindowsServer",
            "offer": "WindowsServer",
            "sku": "2016-Datacenter",
            "version": "latest"
        }
    },
    "licenseType": "Windows_Server",
    "osProfile": {
            "computerNamePrefix": "[parameters('vmssName')]",
            "adminUsername": "[parameters('adminUsername')]",
            "adminPassword": "[parameters('adminPassword')]"
    }
Note

Support for deploying a virtual machine scale set with AHUB benefits through PowerShell and other SDK tools is coming soon.

Next steps

Read more about Azure Hybrid Use Benefit licensing.

Learn more about using Resource Manager templates.

Learn more about Azure Hybrid Use Benefit and Azure Site Recovery make migrating applications to Azure even more cost-effective.