Unfortunately previous convenient methods that were implemented in Visual Studio 2019 on the basis of Server Explorer (i.e. Azure resoutces and services could be displayed and were accessible permitting Attach To Process and WaWorkerHost.exe that allowed remote debugging) is no longer available in VS 2019 or 2022. Alternate methods suggested in the existing documentation are only partially complete.
I had to use the following process to enable remote debugging of a cloud service (extended) from Visual Studio 2022:
- Publish using Publish (extended) with the enable remote desktop checked.
- Enter a login and password combination in the dialog that should appear for later reference.
- On a different machine I went to the Azure portal and selected the worker role in Roles and Instances of the cloud service and hit the Connect button. Then click the downloaded file and a remote desktop appears.
- In the remote desktop go to Settings->System->Remote Desktop and I tried to enable it and a Confirm screen appeared and after OK the setting remained unenabled(?) but it didn't seem to matter.
- In the remote desktop I installed the remote tools for Visual Studio 2022.
- I went to where I installed the remote tools (C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Remote Debugger\x64) and ran msvscom.exe.
- This starts a remote debugger that has options for port and permissions.
- I selected the default settings.
- I returned to the Publish machine and under Debug selected Attach To Process. With Connected Type to Default and Connection Target to the ip of the service with the port 4024 e.g. 13.54.234.35:4024 (matching the entry in the .csdef file
<Endpoints>
<InputEndpoint name="RemoteDebug" protocol="tcp" port="4024"localPort="4024"
- A dialog pops up asking for the login and password that you entered from the Publish remote desktop option.
- Scroll down to WaWorkerHost.exe and select the Attach button.
- The Output window of VS then displays Debug messages and allows setting breakpoints. Voila!
The clearly is a difference between the process for a cloud service and a Web App.
This YouTube video was helpful:
https://www.youtube.com/watch?v=NMsZAvzwLoE
Some of the documentation might be relevant:
https://learn.microsoft.com/en-us/visualstudio/debugger/remote-debugging-csharp?view=vs-2019
Entries in the .cscfg might be problematic and also you may need to set IAM permissions for cloud service access. The documentation indicates other ways to establish a remote debugging scenario but this was the only one that worked for me.