Azure Cosmos DB: Retrieving document by GUID

Viewed 645

I have stored a document with a GUID in a Cosmos DB container. When I attempt to retrieve the same document with a Where() clause, however, it fails to return the document.

Here is my C# code to query document:

var application = await client
  .CreateDocumentQuery<Document>(collectionLink, feedOptions)
  .Where(d => d.Id == "b0e6b18a-54rgf-497d-45g7-bcb17afbdtyh")
  .Where(d => d.Type == "application")
  .Where(d => d.DeletedDateTime == null)
  .AsDocumentQuery()
  .ExecuteNextAsync<Document>(cancellationToken)
  .ConfigureAwait(false);

And here is a sample Json file in the Azure Cosmos DB:

{
    "id": "b0e6b18a-54rgf-497d-45g7-bcb17afbdtyh",
    "Type": "application",
    "ApplicationId": "b0e6b18a-54rgf-497d-45g7-bcb17afbdtyh",
    "Name": "test",
    "Description": "test application.",
    "Company": "test",
    "OwnerEmailId": "xyz@xyz.com",
    "CreatedDateTime": "",
    "ModifiedDateTime": "",
    "DeletedDateTime": null,   
    "Resources": [],
    "_rid": "removedId",
    "_self": "removedId",
    "_etag": "removedID",
    "_attachments": "attachments/",
    "_ts": 1567604515
}

In the final output, there are no matching records. What is missing?

Important! this code is working in my Development environment. But it fails in test environment.

0 Answers
Related