Further AVD Adventures

I mentioned in a previous post that we were experimenting with Azure Virtual Desktop.  One of the things that I need to be able to do is launch from a web page.  We have figured out how to do that using this info:  Uniform Resource Identifier schemes with the Remote Desktop client for Azure Virtual Desktop (preview) | Microsoft Learn

But you have to look up the Workspace ID and Application ID.  You come up something like this:

ms-avd:connect?workspaceId=1638e073-63b2-46d8-bd84-ea02ea905467&resourceid=c2f5facc-196f-46af-991e-a90f3252c185&username=user@contoso.com&version=0

That is great, but you have to use a script to get the IDs.   Not hard, but you have to pass a log of information in, and I am lazy.  I thought it might be worth writing a script to pull all the app ids for the Workspace.

If you run this bit (after authentication and defining variables):

$workspace = Get-AzWvdWorkspace -Name $WorkSpaceName -ResourceGroupName $WorkspaceRG

$workspace.ApplicationGroupReference

You get a list of the App Group references that looks something like this:

PS C:\Users\Michael> $workspace.ApplicationGroupReference
/subscriptions/<SubscirptionID>/resourcegroups/<AppGroupResourceGroup>/providers/Microsoft.DesktopVirtualization/applicationgroups/<Application-Group-Name>

/subscriptions/<SubscirptionID>/resourcegroups/<AppGroupResourceGroup>/providers/Microsoft.DesktopVirtualization/applicationgroups/<Application-Group-Name>

/subscriptions/<SubscirptionID>/resourcegroups/<AppGroupResourceGroup>/providers/Microsoft.DesktopVirtualization/applicationgroups/<Application-Group-Name>

/subscriptions/<SubscirptionID>/resourcegroups/<AppGroupResourceGroup>/providers/Microsoft.DesktopVirtualization/applicationgroups/<Application-Group-Name>

You will get all the AppGroups associated with the Workspace.  You can break that up and get the app ids with the following:

$SubsrciptionName = “<YourSubscriptionName>”
$WorkSpaceName = “<WorkspaceName>”
$WorkspaceRG = “<WorkspaceResourceGroup>”



Connect-AzAccount


Set-AzContext -Subscription $SubsrciptionName


$workspace = Get-AzWvdWorkspace -Name $WorkSpaceName -ResourceGroupName $WorkspaceRG
$workspaceID = $Workspace.ObjectID
$appGroupReference = $workspace.ApplicationGroupReference


Foreach ($appGroup in $appGroupReference) {
     $AppGroupParts = $appGroup -split “/”
     $apps = Get-AzWvdApplication -ApplicationGroupName $AppGroupParts[8] -ResourceGroupName $AppGroupParts[4] | Select-Object Name, FilePath, ObjectId
     foreach ($app in $apps) {
         Write-Host “”
         Write-Host “*********************************************”
         Write-Host “To launch $($app.Name) use the following:”
         Write-Host “ms-avd:connect?workspaceId=$workspaceID&resourceid=$($app.ObjectId)&username=<your@domain.com>&version=0”

     }

}

Leave a Reply