This post has been republished via RSS; it originally appeared at: IIS Support Blog articles.
Recently I was involved in troubleshooting a bot case where a system.net call from the bot was failing. We wanted to grab dotnet-traces as that gives us best information from system.net perspective. One way would be to run the bot project locally and then run dotnet-trace for the dotnet process there. But if the issue only happens in the Azure deployed bot, things become a little complicated.
These steps below helped to capture dotnet-trace from Azure app service directly:
- Go to the Kudu Console for your App service : https://<webappname>.scm.azurewebsites.net
- Go to the Debug Console :
- Run dotnet tool install --global dotnet-trace to install the dotnet trace CLI.
- Set the environment variable as : set PATH=%PATH%;%USERPROFILE%\.dotnet\tools
- Now find out the process ID of your dotnet core process by clicking on the “process Explorer” In the Kudu console :
- Once you have the process ID, run the command as below :
NOTE : Please do not forget to give the duration parameter ---- Because in Kudu console you will not be able to manually stop (By pressing “Enter” Or “Ctrl + C” --- It is not an actual console after all :squinting_face_with_tongue: )
- Make sure you reproduce the issue within the set duration and once it is done and trace is collected, you can directly download that trace from kudu console :
- Once you have the trace, you can open it in Perfview.
I have used the above dotnet-trace commands as I was specifically interested in System.Net events, and you can alter the command as per your need.
Reference : dotnet-trace diagnostic tool - .NET CLI | Microsoft Docs
What if the app is running on Linux app service ?
In case of Linux app service, Do the same and go to Kudu console and here you can go to SSH :
You can use “top” command to get the process ID of the process running your app.
And then normally run the dotnet-trace collect command (In Linux app service, it is already installed, and you can also stop the command using Ctrl + C in Linux SSH :smiling_face_with_smiling_eyes:)
See screenshot below for reference.
Now to download this trace, just access the URL appname.scm.azurewebsites.net/vfs/(path-to-file)
In this example : https://pglinuxapp.scm.azurewebsites.net/api/vfs/dotnet_20220211_053206.nettrace (It will say path not found…but your browser will download the file)
I hope this helps!