Home / Azure

AzureTroubleshootingIntermediate

Azure Virtual Desktop session host shows Unavailable or Needs Assistance: agent, registration and SxS listener fixes

AVD session hosts stuck in Unavailable, Needs Assistance or Upgrading and users can't connect. Read the health checks, fix agent registration, the SxS stack listener and blocked URLs.

Deepak Bhardwaj7 min read

Applies toAzure Virtual Desktop (ARM-based host pools), Windows 10/11 multi-session and Windows Server session hosts, Az.DesktopVirtualization PowerShell module, Log Analytics AVD diagnostics

Symptom

Users report "no resources available", or the client connects and fails right away. In the portal, under Host pools > your pool > Session hosts, one or more hosts show Unavailable, Needs Assistance, Upgrading or Upgrade Failed instead of Available.

The broker only sends new sessions to hosts it thinks are healthy. If every host in a pool is Unavailable, the pool is down, even when the VMs are running.

What each status means

Status Gets new sessions? What it means First move
Available Yes All health checks passed Nothing
Needs Assistance Yes A non-fatal check failed (monitoring agent, metadata service or URL check) Fix it before it gets worse; users may see a degraded experience
Shutdown No VM is shut down Start the VM, check your scaling plan
Unavailable No VM is off, or a fatal check failed (domain join, domain trust, SxS stack listener) Read the failed health check
Upgrading Yes Agent update in progress Wait; if stuck, reinstall the agent
Upgrade Failed Yes Agent update failed; existing sessions are fine Check WVD-Agent-Updater events

Tip

If you shut a VM down and it shows Unavailable instead of Shutdown, it probably powered off before it could report its status. That isn't a fault.

Step 1: read the failed health check

Use the Az.DesktopVirtualization module to see the status, last heartbeat and health check results for every host in the pool:

$rg   = "rg-avd-prod"
$pool = "hp-prod-pooled"

Get-AzWvdSessionHost -ResourceGroupName $rg -HostPoolName $pool |
  Select-Object Name, Status, AllowNewSession, Session, LastHeartBeat, AgentVersion, UpdateState |
  Format-Table -AutoSize

To see which check failed on one host:

$sh = Get-AzWvdSessionHost -ResourceGroupName $rg -HostPoolName $pool -Name "avd-prod-0.contoso.local"
$sh.SessionHostHealthCheckResult | ConvertTo-Json -Depth 5

If the host pool sends diagnostics to Log Analytics, this query shows which hosts changed state and when:

WVDAgentHealthStatus
| where TimeGenerated > ago(24h)
| summarize arg_max(TimeGenerated, Status, AgentVersion, SxSStackVersion, LastHeartBeat) by SessionHostName
| where Status != "Available"
| order by TimeGenerated desc

Fatal checks are Domain joined, Domain trust and Side-by-side (SxS) Stack Listener. Non-fatal checks are the Geneva Monitoring Agent, the metadata service check and the URL check. App Attach failures are non-fatal, but they break the affected apps.

Step 2: take the host out of rotation

Before you work on a host that is still partly taking sessions, stop new sessions from landing on it:

Update-AzWvdSessionHost -ResourceGroupName $rg -HostPoolName $pool `
  -Name "avd-prod-0.contoso.local" -AllowNewSession:$false

Get-AzWvdUserSession -ResourceGroupName $rg -HostPoolName $pool -SessionHostName "avd-prod-0.contoso.local" |
  Select-Object Name, UserPrincipalName, SessionState

Warning

Reinstalling the agent or the SxS stack, or restarting the VM, disconnects active users. Unsaved work in their sessions is lost. Send a message or wait for the sessions to drain first.

Step 3: check the agent on the VM

You can't RDP through AVD to a broken host. Use Bastion, or run these through Run Command (az vm run-command invoke --command-id RunPowerShellScript).

Get-Service RDAgentBootLoader | Select-Object Name, Status, StartType

Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\RDInfraAgent" |
  Select-Object IsRegistered, RegistrationToken

# Listener state: look for rdp-sxs... in the Listen state
qwinsta.exe

Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='WVD-Agent','WVD-Agent-Updater','RDAgentBootLoader'; StartTime=(Get-Date).AddHours(-12)} -MaxEvents 50 |
  Select-Object TimeCreated, Id, ProviderName, Message | Format-List

A healthy, registered host shows IsRegistered = 1 and a blank RegistrationToken.

Map the event to the cause

Event / message Cause Fix
3277 INVALID_REGISTRATION_TOKEN or EXPIRED_MACHINE_TOKEN Registration key expired or wrong Re-register with a new key (step 4)
3277 INVALID_FORM Agent can't reach the broker (firewall, proxy, DNS) Open the required AVD URLs
3277 InstallationHealthCheckFailedException SxS stack listener broken Reinstall the SxS stack (step 5)
3277 ENDPOINT_NOT_FOUND Broker has no endpoint for the host, often because the host was removed from the pool Re-register
3277 InstallMsiException Another install is running, or Group Policy blocks msiexec.exe Wait for the other install; check policy with rsop.msc
3277 DownloadMsiException OS disk full Free space, then let the agent retry
3389 MissingMethodException Agent update rolled back; .NET Framework older than 4.7.2 Install .NET 4.7.2 or later
3703 RD Gateway Url: is not accessible Gateway URLs blocked Fix firewall or proxy rules
3019 Web socket transport URLs blocked Fix firewall or proxy rules
No heartbeat, RDAgentBootLoader stopped Service crashed or timed out at boot (events 7000/7011) Start the service; raise ServicesPipeTimeout

For URL problems, run WVDAgentUrlTool.exe from the agent install folder on the host. It lists every required endpoint that the host can't reach. If you use a proxy, bypass the metadata service: netsh winhttp set proxy proxy-server="http=<proxy>" bypass-list="169.254.169.254".

Step 4: re-register with a fresh token

Generate a new registration key for the pool. It has to expire between 1 hour and 27 days from now:

$expiry = (Get-Date).ToUniversalTime().AddHours(4).ToString('yyyy-MM-ddTHH:mm:ss.fffffffZ')
$reg = New-AzWvdRegistrationInfo -ResourceGroupName $rg -HostPoolName $pool -ExpirationTime $expiry
$reg.Token   # treat this as a secret

If only the token has expired, update it in place on the VM:

$newKey = "<token from above>"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\RDInfraAgent" -Name "IsRegistered" -Value 0 -Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\RDInfraAgent" -Name "RegistrationToken" -Value $newKey -Force
Restart-Service RDAgentBootLoader
# After a minute: IsRegistered should be 1 and RegistrationToken blank
Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\RDInfraAgent" | Select-Object IsRegistered, RegistrationToken

If the agent itself is broken, do a full reinstall:

  1. On the VM, uninstall Remote Desktop Agent Boot Loader, Remote Desktop Services Infrastructure Agent, Remote Desktop Services Infrastructure Geneva Agent and Remote Desktop Services SxS Network Stack. Restart.
  2. Remove the session host object from the pool: Remove-AzWvdSessionHost -ResourceGroupName $rg -HostPoolName $pool -Name "avd-prod-0.contoso.local".
  3. Install the agent and paste the new token when it asks. Then install the boot loader and restart.

Caution

Removing the session host object signs out every user session that's still on it. If the host is personal (assigned), you'll also need to assign it to the user again.

Step 5: repair the SxS stack listener

If qwinsta doesn't show an rdp-sxs listener, or the SxS health check failed, reinstall the newest stack MSI that the agent downloaded:

$sxsMsi = (Get-ChildItem "$env:SystemDrive\Program Files\Microsoft RDInfra\" |
  Where-Object Name -like "SxSStack*.msi" |
  Sort-Object CreationTime -Descending | Select-Object -First 1).FullName
msiexec /i $sxsMsi /quiet

Next, check the listener registry values. In HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\rdp-sxs<version>, fEnableWinStation and fReverseConnectMode should both be 1. Under ...\Terminal Server\ClusterSettings, SessionDirectoryListener should name the current rdp-sxs listener. MSI file names and the listener version change with each stack release, so compare them with what's actually on the host.

Domain join and trust failures

If the Domain joined or Domain trust check fails, the host can't authenticate users. From the VM:

Test-ComputerSecureChannel -Verbose
nltest /sc_verify:contoso.local

If the secure channel is broken, run Test-ComputerSecureChannel -Repair -Credential (Get-Credential) with a domain account that has rights to the computer object. If the VM can't find a domain controller, check its DNS servers before you look at anything else.

When the hosts are healthy again, turn new sessions back on with Update-AzWvdSessionHost ... -AllowNewSession:$true.

Prevent it next time

  • Turn on host pool diagnostics to Log Analytics. Set an alert on WVDAgentHealthStatus for any host that isn't Available for more than 15 minutes.
  • Generate registration tokens only when you deploy hosts, and keep them short-lived. Don't leave a 27-day token sitting in an image or pipeline variable.
  • Before you change firewall or proxy rules, run WVDAgentUrlTool.exe on one host to confirm the required URLs are still reachable.
  • Keep at least 15–20% free space on the OS disk. Agent and stack updates need room to download.
  • Rebuild hosts from a golden image instead of repairing old ones. When a host breaks, drain it, delete it and redeploy it.