Deploy VMs to dedicated hosts using the Azure PowerShell

This article guides you through how to create an Azure dedicated host to host your virtual machines (VMs).

Make sure that you have installed Azure PowerShell version 2.8.0 or later, and you are signed in to an Azure account in with Connect-AzAccount.


  • Virtual machine scale sets are not currently supported on dedicated hosts.
  • The following VM series are supported: DSv3, ESv3, and Fsv2.

Create a host group

A host group is a resource that represents a collection of dedicated hosts. You create a host group in a region and an availability zone, and add hosts to it. When planning for high availability, there are additional options. You can use one or both of the following options with your dedicated hosts:

  • Span across multiple availability zones. In this case, you are required to have a host group in each of the zones you wish to use.
  • Span across multiple fault domains which are mapped to physical racks.

In either case, you are need to provide the fault domain count for your host group. If you do not want to span fault domains in your group, use a fault domain count of 1.

You can also decide to use both availability zones and fault domains. This example creates a host group in zone 1, with 2 fault domains.

$rgName = "myDHResourceGroup"
$location = "East US"

New-AzResourceGroup -Location $location -Name $rgName
$hostGroup = New-AzHostGroup `
   -Location $location `
   -Name myHostGroup `
   -PlatformFaultDomain 2 `
   -ResourceGroupName $rgName `
   -Zone 1

Create a host

Now let's create a dedicated host in the host group. In addition to a name for the host, you are required to provide the SKU for the host. Host SKU captures the supported VM series as well as the hardware generation for your dedicated host.

For more information about the host SKUs and pricing, see Azure Dedicated Host pricing.

If you set a fault domain count for your host group, you will be asked to specify the fault domain for your host. In this example, we set the fault domain for the host to 1.

$dHost = New-AzHost `
   -HostGroupName $hostGroup.Name `
   -Location $location -Name myHost `
   -ResourceGroupName $rgName `
   -Sku DSv3-Type1 `
   -AutoReplaceOnFailure 1 `
   -PlatformFaultDomain 1

Create a VM

Create a virtual machine on the dedicated host.

If you specified an availability zone when creating your host group, you are required to use the same zone when creating the virtual machine. For this example, because our host group is in zone 1, we need to create the VM in zone 1.

$cred = Get-Credential
New-AzVM `
   -Credential $cred `
   -ResourceGroupName $rgName `
   -Location $location `
   -Name myVM `
   -HostId $dhost.Id `
   -Image Win2016Datacenter `
   -Zone 1 `
   -Size Standard_D4s_v3


If you create a virtual machine on a host which does not have enough resources, the virtual machine will be created in a FAILED state.

Check the status of the host

You can check the host health status and how many virtual machines you can still deploy to the host using GetAzHost with the -InstanceView parameter.

Get-AzHost `
   -ResourceGroupName $rgName `
   -Name myHost `
   -HostGroupName $hostGroup.Name `

The output will look similar to this:

ResourceGroupName      : myDHResourceGroup
PlatformFaultDomain    : 1
AutoReplaceOnFailure   : True
HostId                 : 12345678-1234-1234-abcd-abc123456789
ProvisioningTime       : 7/28/2019 5:31:01 PM
ProvisioningState      : Succeeded
InstanceView           : 
  AssetId              : abc45678-abcd-1234-abcd-123456789abc
  AvailableCapacity    : 
    AllocatableVMs[0]  : 
      VmSize           : Standard_D2s_v3
      Count            : 32
    AllocatableVMs[1]  : 
      VmSize           : Standard_D4s_v3
      Count            : 16
    AllocatableVMs[2]  : 
      VmSize           : Standard_D8s_v3
      Count            : 8
    AllocatableVMs[3]  : 
      VmSize           : Standard_D16s_v3
      Count            : 4
    AllocatableVMs[4]  : 
      VmSize           : Standard_D32-8s_v3
      Count            : 2
    AllocatableVMs[5]  : 
      VmSize           : Standard_D32-16s_v3
      Count            : 2
    AllocatableVMs[6]  : 
      VmSize           : Standard_D32s_v3
      Count            : 2
    AllocatableVMs[7]  : 
      VmSize           : Standard_D64-16s_v3
      Count            : 1
    AllocatableVMs[8]  : 
      VmSize           : Standard_D64-32s_v3
      Count            : 1
    AllocatableVMs[9]  : 
      VmSize           : Standard_D64s_v3
      Count            : 1
  Statuses[0]          : 
    Code               : ProvisioningState/succeeded
    Level              : Info
    DisplayStatus      : Provisioning succeeded
    Time               : 7/28/2019 5:31:01 PM
  Statuses[1]          : 
    Code               : HealthState/available
    Level              : Info
    DisplayStatus      : Host available
Sku                    : 
  Name                 : DSv3-Type1
Id                     : /subscriptions/10101010-1010-1010-1010-101010101010/re
Name                   : myHost
Location               : eastus
Tags                   : {}

Clean up

You are being charged for your dedicated hosts even when no virtual machines are deployed. You should delete any hosts you are currently not using to save costs.

You can only delete a host when there are no any longer virtual machines using it. Delete the VMs using Remove-AzVM.

Remove-AzVM -ResourceGroupName $rgName -Name myVM

After deleting the VMs, you can delete the host using Remove-AzHost.

Remove-AzHost -ResourceGroupName $rgName -Name myHost

Once you have deleted all of your hosts, you may delete the host group using Remove-AzHostGroup.

Remove-AzHost -ResourceGroupName $rgName -Name myHost

You can also delete the entire resource group in a single command using Remove-AzResourceGroup. This will delete all resources created in the group, including all of the VMs, hosts and host groups.

Remove-AzResourceGroup -Name $rgName

Next steps

  • There is sample template, found here, that uses both zones and fault domains for maximum resiliency in a region.

  • You can also deploy dedicated hosts using the Azure portal.