Workload / Flow for preparing Azure Virtual Desktop users on the LoadGen Agent

This article helps to get an overview of how you need to prepare your LoadGen infrastructure

Make sure you read this article first: Tutorial: Prepare LoadGen for testing or monitoring Azure Virtual Desktop

Windows Virtual Desktop (WVD) is renamed to Azure Virtual Desktop (AVD)

But not everything is yet renamed, so in some cases, we still use WVD instead of AVD.


The Azure Virtual Desktop flow resides on variables, which will be reused in the actual preparation of the LoadGen Agents. You can find the variables by pressing the Home icon in the General Simulation Flow, and the tab page Custom Objects. In this Flow, we have the following variables available:
  • Azure_Username: used by the action Iterate over datasource.
  • Azure_Password: used by the action Iterate over datasource.
  • Azure_AppId: this variable must be changed accordingly to your own environment, the Application ID of your Azure Active Directory application.
  • Azure_TenantId: this variable must be changed accordingly to your own environment, the Tenant ID of your Azure Active Directory.
  • WVD_ClassicMode: this variable must be changed accordingly to your own environment, true or false (default false) regarding your type of WVD environment (Classic or ARM).
  • WVD_ResourceName: this variable must be changed accordingly to your own environment, the name of the WVD Published Application / Desktop.


In the tab page Repository, you can find the datasource Azure Test Users. Please change the users and password to the test users you want to use in your test. Make sure these test users exist in Azure Active Directory and have an assignment on the AVD Pool.


The AVD LoadGen Prepare Flow assumes you have logged on to the desktop of the LoadGen Agent before it's started. The Flow consists of one application named LoadGen Agent AVD. In this Flow, we have added one Application Block (like a Folder in Windows Explorer - a placeholder for your actions) named Prepare.


Double-clicking the Prepare icon will start the LoadGen Studio Recorder. In the Recorder, we have added multiple steps to prepare your LoadGen Agents for using Azure Virtual Desktop.


Step 1: Iterate over the datasource Azure Test Users

First, we will iterate over all your Azure test users, from the data source we mentioned earlier in this article. We will process each user and retrieve the WVD resources for that user, and starting the right AVD resource based on the WVD_ResourceName variable. We created a custom code action for these steps named Get AVD Resource:


Get WVD Resource
' START Get WVD Resource

Private Sub FreeCode_b9b677a183084691a7a594375fc81a48()
' Everything between 'ExecuteGuid' and END will be saved.
' All other changes you make in this codefile will be lost.
dim wvdResources as List(of String) = DUAFHost.GetWVDResources(Azure_AppId, Azure_TenantId, Azure_Username, Azure_Password)

if wvdResources.Count > 0 Then
'Check if we have resources if not ReturnMessage stays False
ReturnMessage = DuafHost.StartWVDResource(Azure_AppId, Azure_TenantId, System.Linq.Enumerable.FirstOrDefault(of String)(wvdResources, Function(nameWVD) nameWVD.ToLower() = WVD_ResourceName.ToLower()), Azure_Username, Azure_Password, False)
End If

End Sub
' END b9b677a1-8308-4691-a7a5-94375fc81a48

Step 2: Check the status of the current user

After retrieving the AVD Resource RDP file we will first check the status of the user which is processed:
  1. Not yet been processed.
  2. Logged in to Azure AD, but not in the Windows Credential Manager.
  3. Logged in to Azure AD and in the Windows Credential Manager (so the session will start for the current user).
If Step 1 is successful the variable ReturnMessage will be True. We will now check the status of the user.

  1. The first step is to check if there is an AVD Session for the current user. If there is an AVD Session for this user we will stop the workload by setting the variable ContinueWVDLoginProcess to False and exit the Repeat loop.
  2. If the AVD Session is not yet started for the current user we will continue checking the current status of the user. The next check will be if we get a message from the Windows Credential Manager (Check Step 4). If the form Window Security is active we will continue with the UserAction block (a collection of actions double-click to open it). After processing the UserAction block we will set the variable ContinueWVDLoginProcess to False and exit the Repeat loop.
  3. If we don't see the Windows Security form, we assume we have not yet logged on and we will start the process from the beginning (see step 3):
    1. Log in to Azure AD.
    2. Log in to the Windows Credential Manager.
    3. Check if the AVD Session is started.

Step 3: Log in to Azure AD

If we have retrieved the AVD resource connection file (.rdpw), we will launch the Remote Desktop process: msrdc with the retrieved AVD connection file. We will send the username and the password to the following login screen:
We must handle a couple of actions in this process:
  1. We will wait for a button called: Use another account and press it.
  2. We will wait for an edit control called: Enter your email, phone, or Skype and press it.
    1. We will type the user name.
    2. We will press the Next button.
    3. We will type the password.
  3. We will wait for a button called: Sign-in and press it.
  4. We will wait for a hyperlink called: No, sign in to this app only and press it.
The actions are outlined in the below pictures (we have a lot of checks/validations and logging included, so you can directly pinpoint any issues you may encounter):

Step 4: Add account to Windows Credential Manager

The next phase in the flow is to add the identity to the Windows Credential Manager.
This is a mandatory step if you don't have ADFS enabled. A window will open asking for the user's password.

Unfortunately, the window doesn't have focus, so we first force the focus.
If LoadGen finds the control named Password, we can continue.

Step 5: AVD session

The last step is to wait for the AVD session to start, if it's started we will stop the AVD process and continue preparing the next user.

Send to the database and LoadGen Director actions

As mentioned earlier we have a lot of logging incorporated in our Flow, all of the Send message actions will be stored in the database and the LoadGen Director.


Was this article helpful?
0 out of 0 found this helpful