prateek Chaudhary
prateek Chaudhary

Reputation: 1

I am using Visualize analytics query in Logic app. I cannot find a way to write in a query which app insights data source to be used

The query works fine on analytics portal but not under Visualize analytics query in the Logic app. I am also not sure how to tell a logic app to query on the certain data source. I use below query :

requests
| where timestamp > ago(20m)
| summarize failedCount=sumif(itemCount, success == false and (client_Type != "Browser")), impactedUsers=dcountif(user_Id, success == false and (client_Type != "Browser")), totalCount=sum(itemCount) by operation_Name
| union(requests
| summarize failedCount=sumif(itemCount, success == false and (client_Type != "Browser")), impactedUsers=dcountif(user_Id, success == false and (client_Type != "Browser")), totalCount=sum(itemCount)
| extend operation_Name="Overall")
| where failedCount > 0
| order by failedCount desc

I get below error in logic app:

"Message": "Microsoft.ApplicationInsights.DraftClient.Exceptions.DraftApiQueryFailedException: Failed to query Draft API. Status code: NotFound, Content: {\"error\":{\"message\":\"The application could not be found\",\"code\":\"ApplicationNotFoundError\"

Upvotes: 0

Views: 792

Answers (1)

theadzik
theadzik

Reputation: 138

I had the same problem. The problem was with the connection between the logic app and application insights and not the query itself.

I created the key with PowerShell:

$ApplicationInsightsAPI = New-AzApplicationInsightsApiKey -ResourceGroupName $ResourceGroupName -Name $ApplicationInsightsName -Permissions ReadTelemetry -Description "$ConnectionNameAI"

Then I took $ApplicationInsightsAPI and pass ID and ApiKey properties to the connection creation command:

$connection = New-azResource -Properties @{"api" = @{"id" = "subscriptions/" + $subscriptionId + "/providers/Microsoft.Web/locations/" + $ResourceLocation + "/managedApis/" + $api}; "displayName" = $ConnectionNameAI; "parameterValues"= @{"username" = $ApplicationInsightsAPI.Id; "password" = $ApplicationInsightsAPI.ApiKey;} } -ResourceName $ConnectionNameAI -ResourceType "Microsoft.Web/connections" -ResourceGroupName $ResourceGroupName -Location $ResourceLocation -Force

But this is NOT CORRECT. "Username" should be Application ID of the Application Insights, not ID of the API Key.

Upvotes: 0

Related Questions