C
C#3y ago
ZBAGI

Azure app insights api query problem

Hi, I trying to query application insights via api by using provided nuget package - https://github.com/Azure/azure-sdk-for-net/blob/Azure.Monitor.Query_1.1.0/sdk/monitor/Azure.Monitor.Query/README.md everything works like in example. Except when I replace query "AzureActivity | top 10 by TimeGenerated" with what i need ie. requests it seems to not understand request scope. This query works without any problem when used in azure portal, so why is it complaining in api ? I made sure i use correct workspace and credentials. Here is the code:
string workspaceId = "<redacted>";

var auth = new ClientSecretCredential("<redacted>", "<redacted>", "<redacted>");
var client = new LogsQueryClient(auth);

var response = await client.QueryWorkspaceAsync(
workspaceId,
"requests",
new QueryTimeRange(TimeSpan.FromDays(1)));
string workspaceId = "<redacted>";

var auth = new ClientSecretCredential("<redacted>", "<redacted>", "<redacted>");
var client = new LogsQueryClient(auth);

var response = await client.QueryWorkspaceAsync(
workspaceId,
"requests",
new QueryTimeRange(TimeSpan.FromDays(1)));
Azure.RequestFailedException: 'The request had some invalid properties
Status: 400 (Bad Request)
ErrorCode: BadArgumentError

Content:
{"error":{"message":"The request had some invalid properties","code":"BadArgumentError","correlationId":"<redacted>","innererror":{"code":"SemanticError","message":"A semantic error occurred.","innererror":{"code":"SEM0100","message":"'where' operator: Failed to resolve table or column expression named 'requests'"}}}}
Azure.RequestFailedException: 'The request had some invalid properties
Status: 400 (Bad Request)
ErrorCode: BadArgumentError

Content:
{"error":{"message":"The request had some invalid properties","code":"BadArgumentError","correlationId":"<redacted>","innererror":{"code":"SemanticError","message":"A semantic error occurred.","innererror":{"code":"SEM0100","message":"'where' operator: Failed to resolve table or column expression named 'requests'"}}}}
Any idea what is wrong ?
GitHub
azure-sdk-for-net/README.md at Azure.Monitor.Query_1.1.0 · Azure/az...
This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/dotnet/azure/ or our vers...
1 Reply
ZBAGI
ZBAGIOP3y ago
Well i narrowed down problem to the scope based on the azure portal i can see that if i select DefaultWorkspace scope there is no request resource, but if i switch to the app scope it does. How do i select scope via api ? I checked all docs but there is no mention about it
Want results from more Discord servers?
Add your server