Redirect Windows Azure Pack Desktop Connections through RDS Gateway
There are two different option to connect to a Virtual Machine in Windows Azure Pack. You can use the Console Connect with Remote Desktop Gateway or direct Remote Desktop Connection which will generate a RDP file with the Virtual Machine IP Address. Because Console Connect is quite limited, I modified the script which creates the RDP file with my Remote Desktop Gateway included.
On the Windows Azure Pack Tenant Site Server go to %SystemDrive%\inetpub\MgmtSvcTenantSite\Content\VM\Scripts\Commands and edit the VM.Command.VirtualMachine.RemoteDesktop.js script.
requestUrl = service.getRdpUrlForRemoteDesktop(null, null, null, dataContext.activeVM.displayName, viewModel.getSelectedIpAddress());
requestUrl = service.getRdpUrlForRemoteDesktop(null, null, null, dataContext.activeVM.displayName, viewModel.getSelectedIpAddress() + "\r\ngatewayhostname:s:YourRDSGateway.domain.com\r\ngatewayusagemethod:i:2\r\ngatewayprofileusagemethod:i:1\r\npromptcredentialonce:i:1");
Change "YourRDSGateway.domain.com" with your Remote Desktop Gateway Server. Change, add or remove any other parameters if required.
npromptcredentialonce:i:1 - use my RD Gateway credentials for the remote computer.
Save the script, reset IIS and now all Remote Desktop Connections will redirect through your gateway server.
I use this modified script in a production and did not experienced any problems, nevertheless I would recommend backing up your server configuration and testing the script first in your test lab!