AWS AppStream 2.0 home folder "device not ready"

586 Views Asked by At

We are using on-demand instances to serve our applications in desktop view on AppStream 2.0. When we click on our application script the first thing it does is try to ensure that a directory exists in the "D:\PhotonUser\My Files\Home Folder" folder.

We are experiencing an issue with the "device not ready" exception and occasionally "access denied". We have found that everything works if we add a 30-second delay at the start of our script (before it checks and creates the folder if missing).

Does anyone know if the delay in the home folder readiness is to be expected, or does anyone know of any nice ways to poll for readiness in Powershell?

Thanks for taking the time to look

1

There are 1 best solutions below

1
On BEST ANSWER

There is a registry key you can check to see if the Home Folder has mounted.

$regHive = "HKLM:\SOFTWARE\Amazon\AppStream\Storage\$Env:AppStream_UserName"
function Get-HomeFolderMountStatus {
  Get-ChildItem -Path $regHive `
    | Where-Object { $_.Name.EndsWith('HomeFolder') } `
    | Get-ItemPropertyValue -Name MountStatus
}

Write-Output "Mount status: $(Get-HomeFolderMountStatus)"

# status values can be found at
# https://docs.aws.amazon.com/appstream2/latest/developerguide/use-session-scripts.html#use-storage-connectors-with-session-scripts
while ("$(Get-HomeFolderMountStatus)" -ne '2') {
  Start-Sleep -Seconds 3

  Write-Output "Mount status: $(Get-HomeFolderMountStatus)"
}

# now that the folder has mounted, continue with your script

It does take too long to mount the Home Folder. I'm seeing it take over 30 seconds, which eats up far too much of the 60-second script allotment in my opinion.