How to find and shut down idle Azure Virtual Desktop hosts

5 min readMarkdown version

Short answer

Idle hosts are session hosts that are powered on with no active users, and they bill for compute the whole time. Find them by comparing powered-on hours with real session activity, then let an autoscale scaling plan deallocate them: pooled host pools deallocate emptied hosts after ramp-down, and personal host pools deallocate or hibernate a desktop after its user has been disconnected or signed out for a set number of minutes. Use drain mode when you need to empty a specific host before maintenance.

What idle actually means

A session host is idle when it is running and nobody is using it. The bill does not care: a host that is powered on keeps billing compute whether it has forty sessions or none. The three situations that produce idle hosts look different and need different fixes.

  • Empty pooled hosts: A pooled host pool scaled out for the morning peak and never scaled back in. Sessions ended, the hosts stayed on.
  • Parked personal desktops: One user, one VM. The user went home, disconnected, and the desktop kept running until morning or all weekend.
  • Forgotten hosts: Test hosts, old pools and hosts left over from a migration. They are powered on, in no schedule, and no one is watching them.

How to find them

Compare two numbers per host over a full month: hours powered on, and hours with at least one session. The gap is your idle time. Looking at one day misleads, because a quiet Tuesday is not a quiet month.

Session data comes from the connection and session records collected in a Log Analytics workspace for the host pool, which is also what load-based scaling reads. If a client has no workspace, you can still find the obvious cases by listing hosts that are powered on outside the client's working hours.

Check forgotten hosts separately. They are not in any host pool schedule, so they will not show up as a scaling problem. Look for powered-on VMs in the client's resource groups that no host pool lists as a session host.

Pooled host pools: let autoscale empty and deallocate

For pooled host pools, a scaling plan has ramp-up, peak, ramp-down and off-peak phases. During ramp-down the plan drains hosts and, per Microsoft's description, after it signs out the remaining user sessions it then deallocates the VM. The setting that has to be right first is the maximum session limit: Microsoft states that pooled autoscale needs a configured MaxSessionLimit on the host pool, and you must not leave it at the default value.

Keep a minimum number of hosts warm. A pool that drops to zero hosts makes the first user of the day wait for a VM to boot, and that complaint costs more goodwill than the saved hours earn.

Personal host pools: act on the user's session state

Personal scaling plans work on what the user is doing rather than on a pool-wide load. In each phase you choose what happens when a user has been disconnected for a number of minutes, and what happens when they have been signed out for a number of minutes. Microsoft documents a range of 0 to 360 minutes for both, and the action can be to deallocate the VM, hibernate the desktop, or do nothing.

Turn on Start VM on Connect if autoscale does not start hosts during ramp-up. Microsoft strongly recommends it in that case, because it lets a deallocated personal desktop start when its user connects, instead of leaving them with a desktop that is off.

Hibernation has a catch. It has to be enabled on the session hosts, and Microsoft states that FSLogix and App Attach do not currently support hibernate, so do not enable it for personal host pools that use either. In those pools, choose deallocate.

Draining a specific host before you switch it off

Autoscale handles the routine case. For a host you want to empty by hand, set it to drain mode. Microsoft describes the effect: a host in drain mode accepts no new sessions, new connections go to the next available host, and existing sessions stay active until the user signs out or an administrator ends the session. Administrators can still connect to the host directly.

That makes drain mode the safe first step for maintenance or removal: wait for the sessions to end, then deallocate. It does not end anyone's session, so it will not cut users off, and it will not empty the host on its own either.

Across many clients

The settings above are per host pool, so the work is repeating them and proving they took effect for every client. rugged.sh applies schedule and load-based autoscale profiles per customer tenant and deallocates rather than stops. Schedule-based scaling needs nothing else connected; load-based scaling needs a Log Analytics workspace on that tenant. The saving shown next to each client is a model, not a measurement of hours actually removed, so confirm it against the client's Azure bill after a full billing month.

Questions people ask

How do I know an AVD session host is idle?
Compare how long it was powered on with how long it had at least one user session, across a full month. The gap is idle time. Hosts that are on outside the client's working hours, or that no host pool lists, are the quickest ones to spot.
Will autoscale cut off users who are still signed in?
On pooled host pools, Microsoft describes ramp-down as draining hosts and then signing out remaining sessions before it deallocates the VM, so review the sign-out settings on the scaling plan before you enable it. On personal host pools, the action only fires after the user has been disconnected or signed out for the number of minutes you set.
Should I deallocate or hibernate personal desktops?
Deallocate unless you need the desktop to resume exactly where it was. Hibernation needs to be enabled on the hosts, and Microsoft says it is not supported with FSLogix or App Attach, so pools using either should deallocate.
Does deallocating an idle host stop all of its cost?
No. Deallocation stops the compute charge only. Managed disks and some networking resources keep billing while the VM is deallocated, so a fleet with aggressive scheduling still carries a disk cost for every host it keeps.

Sources

Microsoft's behaviour described above was read from these pages on the dates shown. Claims that come from our own testing against a live Azure subscription carry that date inline.

Related

Try it on one client

The free tier covers one customer tenant and five users, with no time limit, against your own Azure subscription. Paid plans are priced per tenant, not per user.