9
votes

We're using Application Insights within an Azure App Service (some Web API) which queries an Azure Cosmos DB in .NET Core 2.1. The querying is done using a DocumentClient object from the Nuget package Microsoft.Azure.DocumentDB.Core 1.10.0, and on this client we're calling the CreateDocumentQuery<T>(Uri, FeedOptions) extension method.

Now from a user's perspective the querying seems to work fine. However, looking at Application Insights we are presented with a rather large number of dependency failures concerning the Cosmos DB. I'll try to visualize what I'm seeing in the Azure portal:

--------------------------------------------------------------------------------------------------
| Event                                                                        | Res. | Duration |
--------------------------------------------------------------------------------------------------
| ▼ web-api-resource-name POST api-endpoint-name                               | 200  | 149.1 ms |
--------------------------------------------------------------------------------------------------
|   AZURE DOCUMENTDB cosmosdb-name.documents.azure.com | Create/query document | 400  |     4 ms |
--------------------------------------------------------------------------------------------------
|   AZURE DOCUMENTDB cosmosdb-name.documents.azure.com | Query documents       | 200  |     7 ms |
--------------------------------------------------------------------------------------------------
|   AZURE DOCUMENTDB cosmosdb-name.documents.azure.com | Create/query document | 400  |     4 ms |
--------------------------------------------------------------------------------------------------
|   AZURE DOCUMENTDB cosmosdb-name.documents.azure.com | Query documents       | 200  |     5 ms |
--------------------------------------------------------------------------------------------------
|   AZURE DOCUMENTDB cosmosdb-name.documents.azure.com | Create/query document | 400  |     4 ms |
--------------------------------------------------------------------------------------------------
|   AZURE DOCUMENTDB cosmosdb-name.documents.azure.com | Query documents       | 200  |     6 ms |
--------------------------------------------------------------------------------------------------
|   AZURE DOCUMENTDB cosmosdb-name.documents.azure.com | Query documents       | 200  |     6 ms |
--------------------------------------------------------------------------------------------------
|   AZURE DOCUMENTDB cosmosdb-name.documents.azure.com | Query documents       | 200  |    12 ms |
--------------------------------------------------------------------------------------------------

The lines containing the HTTP 400 results are highlighted in red within the Azure portal and are obviously the ones displaying the dependency failures. Now since the overall request seems to result in a HTTP 200 and no errors are returned to the web api, I can only think of this being some internal Cosmos DB querying. And because there are multiple entries for a single request I'm guessing this could be related to some retry policy.

However, since I can't seem to find any further information on the erroneous requests: Can anyone shed some light on this issue?

UPDATE: Here's a screenshot of the Application Insights view within the Azure portal. Slightly different duration values, but same problem.

Screenshot of Application Insights view

Unfortunately, the column containing the Create/query document and Query documents texts is hidden here, since in the Azure portal you'd have to scroll horizontally to view that information.

Thanks in advance, Tobi

1
Is it possible to attach a screenshot (with redacted data)? It will help to better understand the issue.ZakiMa
Dependency failures don't necessarily result in failed requests - for instance, they are wrapped in try/catch and errors are ignored.ZakiMa
@ZakiMa Thanks for helping. I added a screenshot from the Azure portal, I hope, this is what you meant. As I wrote, the overall request seems to work fine for the user (data is returned), we're just trying to understand and minimize the app's failure data.Onkel Toob
Is this information auto-collected?ZakiMa
Yes, this is real-time data directly from Application Insights.Onkel Toob

1 Answers

10
votes

You can ignore 400's as long as query succeeds. They are expected.

Cosmos service will execute query against a single server partition (or Shard). Cross partition queries are expected to be processed by SDK and server rejects with 400. You can control concurrency of SDK execution through FeedOptions.MaxDegreeOfParallism.