I have followed this example of a console mode C# program that has a trace statement and I can see my trace statement in the portal when viewing my application insights azure object and selecting logs...
I've been trying and failing to use the az monitor command. Here is my attempt:
az monitor app-insights query --app c7b4cxxx-xxxx-xxxx-xxxx-cc9d59bd1138 -g rg_csharp_script_demo --analytics-query 'trace'
(1) I'm not sure what to put for the --app! Can someone please guide me on using this command line interface so I can see my trace statement?
(2) How would the command change if I wanted to see my trace statements in my web app or azure function?
(3) What about trace statements in browser resident source code? Is that an option? How would I do that?
(4) Now the comments for that sample C# console mode program say "// Http dependency is automatically tracked!"... How would I see this with the "az monitor" command?
(5) How would I see this http dependency in the portal?
Thanks
Siegfried
Tue Nov 28 Update:
This worked from powershell (but not bash) when using the name of the application insighs instead of the appid.
az monitor app-insights query --apps javascriptbindingtest --analytics-query 'traces' --resource-group rg_csharp_script_demo --offset 3d
So this is good: the main problem is resolved. However, I'm curious why my other attempts did not work using the appid and using the cloud shell:
I carefully followed your directions to fetch the appid from the App Insights on the portal and copy and paste the resource group
az monitor app-insights query --apps c7b4c42d-xxxx-xxxx-xxxx-cc9d59bd1138 --analytics-query 'traces | summarize count() by bin(timestamp, 1h)' --resource-group rg_csharp_script_demo
ERROR: (ResourceNotFound) The Resource 'Microsoft.Insights/components/c7b4c42d-xxxx-xxxx-xxxx-cc9d59bd1138' under resource group 'rg_csharp_script_demo' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Code: ResourceNotFound
Message: The Resource 'Microsoft.Insights/components/c7b4c42d-xxxx-xxxx-xxxx-cc9d59bd1138' under resource group 'rg_csharp_script_demo' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Then I tried it on a cloud prompt:
So why is it not seeing my resource group? This command works from my dev machine so clearly the resource group does exist and I can see it:
Get-AzResource -ResourceGroupName rg_csharp_script_demo | ft
Name ResourceGroupName ResourceType Lo
ca
ti
on
---- ----------------- ------------ --
ASP-rgcsharpscriptdemo-bcd6 rg_csharp_script_demo Microsoft.Web/serverFarms w.
func-csharp-script-demo rg_csharp_script_demo microsoft.insights/components w.
rgcsharpscriptdemoa4c3 rg_csharp_script_demo Microsoft.Storage/storageAccounts w.
func-csharp-script-demo rg_csharp_script_demo Microsoft.Web/sites w.
Failure Anomalies - func-csharp-script-demo rg_csharp_script_demo microsoft.alertsmanagement/smartDetectorAlertRules g.
stgjavascripttest rg_csharp_script_demo Microsoft.Storage/storageAccounts w.
ASP-rgcsharpscriptdemo-beae rg_csharp_script_demo Microsoft.Web/serverFarms w.
javascriptbindingtest rg_csharp_script_demo microsoft.insights/components w.
javascriptbindingtest rg_csharp_script_demo Microsoft.Web/sites w.
Failure Anomalies - javascriptbindingtest rg_csharp_script_demo microsoft.alertsmanagement/smartDetectorAlertRules g.