Azure / azure-cosmos-dotnet-v2

Contains samples and utilities relating to the Azure Cosmos DB .NET SDK
MIT License
577 stars 838 forks source link

DocumentClientException: Entity with the specified id does not exist in the system. #503

Open rameshjanjyam opened 6 years ago

rameshjanjyam commented 6 years ago

accessing a cosmosdb from asp.net core mvc deployed in web app for container error is

DocumentClientException: Entity with the specified id does not exist in the system.

Code

var cosmosAccount = await azure.CosmosDBAccounts.GetByResourceGroupAsync(model.ResourceGroupName, model.CosmosDBNameAccount);
model.IPRangeFilter = cosmosAccount.IPRangeFilter.Split(',').ToList();

var endpointUrl = "*********";
var authorizationKey = "*****************";            

using(var client = new DocumentClient(new Uri(endpointUrl), authorizationKey)){
    var document = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(model.Database, model.Collection, "1"));
    model.SampleDataFromDB.Add((Models.CosmosDB.SampleDataFromDB)(dynamic)document.Resource);               
}

This code works without any issue from localhost but when this is deployed to azure in web app for container it is intermittently failing with error DocumentClientException: Entity with the specified id does not exist in the system. it works sometimes.

can you please help in understanding why this occurs

kirankumarkolli commented 6 years ago

@rameshjanjyam do you mean with the same endpoint the code is working on developer machine but after deploying to "web app for container" it failing?