I have a .NET 6 Worker Service app which is deployed to Azure in a Docker container running under an AppService Web App for Containers. Microsoft has a separate NuGet package for ApplicationInsights, Microsoft.ApplicationInsights.WorkerService, when deploying this type of app and I followed the corresponding documentation here: Application Insights for Worker Service applications (non-HTTP applications).
However, I cannot seem to find the output from the logs anywhere under my app in the Azure Portal. Per the documentation I linked to above, I am using the TelemetryClient
class in the following way:
using (TelemetryClient.StartOperation<RequestTelemetry>("operation"))
try
{
SomthingThatMightFail();
}
catch (Exception ex)
{
TelemetryClient.TrackEvent("Where can I be found in the Azure logs?!");
}
But after spending much time digging thru everything in Azure, I cannot find the data I am explicitly logging using TelemetryClient.TrackEvent()
. Where does this data wind up and how do I view it? ll I’m able to see are things being implicitly or automatically logged by the framework.
2
Answers
If you are using the Microsoft.ApplicationInsights.TelemetryClient you should be able to find your data under customEvents.
I generally enhance the default data with custom data by using the overloaded TrackEvent method…
Now you can search and filter specifically on the customDimensions in App Insights;
You can write kusto queries as one of the other answers demonstrates, or you can explore the data visually using the azure portal by browsing to your Application Insights resource and navigating to the menu item
Events
in the sectionUsage
:You can then filter and split events and create graphs.
An other option would be to navigate to the menu item
Transaction search
in the sectionAnalyze
: