Teams Media Redirection on Azure Virtual Desktop
Yesterday I had a session on this subject on Workplace Ninja Virtual Edition 2021. If you missed that session, I have put together this blog to get you up to date. I did a previous session on wvdtechfest during spring with some disappointing conclusions. But Microsoft has really done their job and enhanced the components. Now it works like a charm!
What is Teams media optimization
If your not using Teams media optimization, AVD is doing all the work. First device redirection of camera and mic from AVD client to the ADV desktop. And then Encoding and encryption of media in Teams. Handeling all communications with Teams service.
This result in high CPU usage and High Bandwith usage. And on top of that, really choppy and bad video experience!
If you enable Teams media optimizations, you move the heavy work from the AVD to the AVD client. Teams receive data from Teams service and redirect all to WebRTC and to the AVD client. The AVD client uses local media optimization and tries to connect directly to the remote Teams User. All encoding and encryption is done on the local AVD client.
This results in much better CPU and bandwidth usage:
As you can se it´s a big difference in both resource usage and also the user experience. Low CPU, low bandwidth and a smooth video experience.
The local media optimization works great if you are on the same LAN as the remote Teams user. But what if your not. and what if your connected to a meeting where there are participants all over the world?
In this case the Teams media optimization will communicate directly to the Teams service. Thi is of course not as good as if using local media optimizations on LAN, but it works great anyway!
Still low CPU and bandwidth usage on the AVD and great performance in Teams!
How do I enable Teams Media Optimization
One great news is that Teams Media Optimization is enabled by default in Azure Gallery images. But be aware that Ms has accidently put an old version of WebRTC on them. Upgrade for a more stable performance.
First, open the docs page about installing Teams on WVD to verify that nothing has changed lately. Use Microsoft Teams on Windows Virtual Desktop. The process is otherwise not that complex:
- Add regkey IsWVDEnvironment Dword = 1 under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Teams
- Install Microsoft Visual C++ Redistributable 2015-2022
- Install Remote Desktop WebRTC Redirector Service
- Install Teams User based install to get the latest and greatest version.
Or Install Teams Machine Wide Installer with:
msiexec /i Teams_windows_x64.msi ALLUSER=1 ALLUSERS=1
(ALLUSER=1 is important, it makes it optimized for VDI)
The User based install is recommended if not using a non persistent desktop without profile management. If using profile management you should include and exclude these path:
To redirect audio and video devices correctly you also need to add three RDP client properties. This can be done in Azure portal on your host pool. This accually not needed if Teams media optimization works. then the camera end mic is never redirected from AVD client to AVD. Instead the media is redirected from the AVD to the AVD client.
- audiocapturemode:i:1 enables audio capture from the local device and redirects audio applications in the remote session.
- audiomode:i:0 plays audio on the local computer.
- camerastoredirect:s:* redirects all cameras
But if you intend to use fallback to use device redirection if Teams media optimization fails, then you must configure the above settings. You can disable Fallback by using reg key. This can be done both on computer level or for specific users by the following regkeys:
- 0 – Fallback mode is enabled (Default when missing)
- 1 – Disable fallback mode
- 2 – Enable audio only
Limitations
In the current release of Teams for AVD there are some limitations.
There is some workarounds to these limitations. If you need to create live events from AVD, you can use the web based Teams client. If you need to use some of the New Meeting Experience features, you can disable Teams media optimizations and run AVD on a VM with dedicated GPU. You will not get the same performance but it will work.
Troubleshoot
If Teams media redirection does not work, you need to check the folowing:
The WebRTC version. As I stated before, Microsoft accidently installed an old version in the gallery images. Make sure you have the latest version installed
Make sure the Webrtc service is up and running. I have seen AVD where this service has been disabled by security policies. It needs to be running for the Teams optimization to work.
If Teams media optimization has been activated after a user logon to the AVD. The profile has some kind of cached setting that blocks the Teams media optimization from being activated. One way to solve this is to remove all Teams files in the local profile under %appdata%\Microsoft\Teams. Or wipe the profile completely.
Performance Tips
After reading Ryam Mangans blog on sizing and performance benchmark testing – windows virtual desktop. I always recommend using AMD based machines in AVD. If you setup an Intel and an AMD side by side you can feel the difference. In this diagram you can see the differences in performance between the green marked machines.
Another performance tip is to always build them with Premium SSD disks. especially when storing profiles or other disk intensive application data on the AVD hard disks.
Also If you gave graphic intense applications, there are Azure VM with GPU. these machines are quite expensive, but could be needed for some applications. My favourites with a good balance between cost and performance is the NV machines.
If you missed my session at Workplace Ninja Virtual Edition 2021, here is the presentation