You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I got the issue "Entity with the specified id does not exist in the system" when I recreated the Containner/Collection in CosmosDB with the same name, here I used Microsoft.Azure.DocumentDB.Core v.2.20, Azure Fuction v.4, and .NET net6.0
To Reproduce
Step 1
Create a container/collection in Cosmos DB with partition name /partitionKey and add data to it Step 2
Run Azure Functions to query and retrieve data in containers Step 3
After the request in step 2 is successful, delete the container/collection and recreate the container/collection with the same name, then re-add the data in it (step 1) Step 4
Execute the request in step 2 (without re-running the Azure Function)
Code Snippets : Startup.cs
using Microsoft.Azure.Documents.Client;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using System;
[assembly: FunctionsStartup(typeof(API.ProbSolve.Startup))]
namespace API.ProbSolve
{
public partial class Startup : IWebJobsStartup
{
IConfiguration Configuration { get; set; }
public void Configure(IWebJobsBuilder builder)
{
var executionContextOptions = builder.Services.BuildServiceProvider()
.GetService<IOptions<Microsoft.Azure.WebJobs.Host.Bindings.ExecutionContextOptions>>().Value;
var currentDirectory = executionContextOptions.AppDirectory;
//// Get the original configuration provider from the Azure Function
var configuration = builder.Services.BuildServiceProvider().GetService();
// Create a new IConfigurationRoot and add our configuration along with Azure's original configuration
Configuration = new ConfigurationBuilder()
.SetBasePath(currentDirectory)
.AddConfiguration(configuration) // Add the original function configuration
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
//// Replace the Azure Function configuration with our new one
builder.Services.AddSingleton(Configuration);
// Register DocumentClient
builder.Services.AddSingleton(x => new DocumentClient(new Uri(Environment.GetEnvironmentVariable("EventGridEndPoint")),
Environment.GetEnvironmentVariable("EventGridKey")));
}
}
}
Fuction1.cs
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Documents.Client;
using System.Linq;
using System.Collections.Generic;
namespace ProbSolve
{
public class Function1
{
private DocumentClient _client;
public Function1(DocumentClient client)
{
_client = client;
}
[FunctionName("Function1")]
public async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
List<dynamic> listObj = new List<dynamic>();
try
{
if (_client == null)
{
string endpointUri = Environment.GetEnvironmentVariable("EventGridEndPoint");
string primaryKey = Environment.GetEnvironmentVariable("EventGridKey");
_client = new DocumentClient(new Uri(endpointUri), primaryKey);
}
string collectionId = "TroubleSolving";
string sqlQueryText = "SELECT * FROM c";
string databaseId = Environment.GetEnvironmentVariable("DatabaseId");
IQueryable<dynamic> query = _client.CreateDocumentQuery(
UriFactory.CreateDocumentCollectionUri(databaseId, collectionId),
sqlQueryText);
foreach (dynamic result in query)
{
listObj.Add(result);
}
}
catch (Exception ex)
{
//return new BadRequestObjectResult(ex.Message);
throw ex;
}
return new OkObjectResult(listObj);
}
}
}
Expected behavior
Container/collection can still be called when recreated with the same name
Actual behavior
The container/collection is not recognized when the container is recreated, the container still refers to the old container
Describe the bug
I got the issue "Entity with the specified id does not exist in the system" when I recreated the Containner/Collection in CosmosDB with the same name, here I used Microsoft.Azure.DocumentDB.Core v.2.20, Azure Fuction v.4, and .NET net6.0
To Reproduce
Step 1
Step 2
Step 3
Step 4
Code Snippets :
Startup.cs
using Microsoft.Azure.Documents.Client;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using System;
[assembly: FunctionsStartup(typeof(API.ProbSolve.Startup))]
namespace API.ProbSolve
{
public partial class Startup : IWebJobsStartup
{
IConfiguration Configuration { get; set; }
public void Configure(IWebJobsBuilder builder)
{
var executionContextOptions = builder.Services.BuildServiceProvider()
.GetService<IOptions<Microsoft.Azure.WebJobs.Host.Bindings.ExecutionContextOptions>>().Value;
var currentDirectory = executionContextOptions.AppDirectory;
//// Get the original configuration provider from the Azure Function
var configuration = builder.Services.BuildServiceProvider().GetService();
// Create a new IConfigurationRoot and add our configuration along with Azure's original configuration
Configuration = new ConfigurationBuilder()
.SetBasePath(currentDirectory)
.AddConfiguration(configuration) // Add the original function configuration
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
//// Replace the Azure Function configuration with our new one
builder.Services.AddSingleton(Configuration);
// Register DocumentClient
builder.Services.AddSingleton(x => new DocumentClient(new Uri(Environment.GetEnvironmentVariable("EventGridEndPoint")),
Environment.GetEnvironmentVariable("EventGridKey")));
}
}
}
Fuction1.cs
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Documents.Client;
using System.Linq;
using System.Collections.Generic;
namespace ProbSolve
{
public class Function1
{
private DocumentClient _client;
}
Expected behavior
Container/collection can still be called when recreated with the same name
Actual behavior
The container/collection is not recognized when the container is recreated, the container still refers to the old container
Environment summary
SDK Version:
Microsoft.Azure.DocumentDB.Core v.2.20.0
Microsoft.Azure.Functions.Extensions v.1.1.0
Microsoft.NET.Sdk.Functions v.4.2.0
.NET Framwork v.6.0
Additional context
Microsoft.Azure.DocumentDB.Core: Entity with the specified id does not exist in the system. More info: https://aka.ms/cosmosdb-tsg-not-found, {"Summary":{"GatewayCalls":{"(404, 0)":1}},"name":"SqlQueryPlanOnCompute","id":"2aa25b82-30fd-490f-8633-e89abc5229e6","start time":"03:10:09:234","duration in milliseconds":34.7934,"data":{"Client Side Request Stats":{"Id":"AggregatedClientSideRequestStatistics","ContactedReplicas":[],"RegionsContacted":[],"FailedReplicas":[],"AddressResolutionStatistics":[],"StoreResponseStatistics":[],"HttpResponseStats":[{"StartTimeUTC":"2023-11-06T03:10:09.2350695Z","DurationInMs":32.6803,"RequestUri":"https://cosmos-xxxxxxxxxx-southeastasia.sql.cosmos.azure.com/dbs/xxxfss==/colls/xxxxxxFc=","ResourceType":"Collection","HttpMethod":"GET","ActivityId":"a484f1c9-caeb-4ba2-b0db-9935ce310b4d","StatusCode":"NotFound","ReasonPhrase":"Not Found"}]}},"children":[{"name":"Get Collection Cache","id":"b2babe00-9b29-424c-abbc-6fb34a1a3ef8","start time":"03:10:09:234","duration in milliseconds":0.0017},{"name":"Read Collection","id":"208e4a97-2ec7-45f4-8cab-b192a3970f66","start time":"03:10:09:235","duration in milliseconds":33.6323,"data":{"Exception Message":"Message: {"Errors":["Resource Not Found. Learn more: https:\/\/aka.ms\/cosmosdb-tsg-not-found"]}\r\nActivityId: a484f1c9-caeb-4ba2-b0db-9935ce310b4d, Request URI: /apps/540517c5-4054-412a-be16-72f3c4660990/services/d6b3ddae-1699-4df4-8552-05c7149c6c29/partitions/e6f134b0-8af5-4b53-bba8-53ad2c27780c/replicas/133203467052463784s, RequestStats: \r\nRequestStartTime: 2023-11-06T03:10:09.2354273Z, RequestEndTime: 2023-11-06T03:10:09.2634136Z, Number of regions attempted:1\r\n{"systemHistory":[{"dateUtc":"2023-11-06T03:09:18.8672709Z","cpu":0.695,"memory":484218580.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.1273,"availableThreads":32764,"minThreads":52,"maxThreads":32767},"numberOfOpenTcpConnection":557},{"dateUtc":"2023-11-06T03:09:28.8773534Z","cpu":0.402,"memory":484125868.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.051,"availableThreads":32764,"minThreads":52,"maxThreads":32767},"numberOfOpenTcpConnection":554},{"dateUtc":"2023-11-06T03:09:38.8875522Z","cpu":0.447,"memory":484122640.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.1728,"availableThreads":32764,"minThreads":52,"maxThreads":32767},"numberOfOpenTcpConnection":554},{"dateUtc":"2023-11-06T03:09:48.8976905Z","cpu":0.564,"memory":484122552.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.1109,"availableThreads":32764,"minThreads":52,"maxThreads":32767},"numberOfOpenTcpConnection":561},{"dateUtc":"2023-11-06T03:09:58.9078613Z","cpu":0.457,"memory":484126492.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.1115,"availableThreads":32764,"minThreads":52,"maxThreads":32767},"numberOfOpenTcpConnection":561},{"dateUtc":"2023-11-06T03:10:08.9180018Z","cpu":0.387,"memory":484126020.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.1128,"availableThreads":32763,"minThreads":52,"maxThreads":32767},"numberOfOpenTcpConnection":564}]}\r\nRequestStart: 2023-11-06T03:10:09.2356102Z; ResponseTime: 2023-11-06T03:10:09.2634037Z; StoreResult: StorePhysicalAddress: rntbd://10.0.1.11:11300/apps/540517c5-4054-412a-be16-72f3c4660990/services/d6b3ddae-1699-4df4-8552-05c7149c6c29/partitions/e6f134b0-8af5-4b53-bba8-53ad2c27780c/replicas/133203467052463784s, LSN: 3845, GlobalCommittedLsn: 3845, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#3845, UsingLocalLSN: False, TransportException: null, BELatencyMs: 26.94, ActivityId: a484f1c9-caeb-4ba2-b0db-9935ce310b4d, RetryAfterInMs: , ReplicaHealthStatuses: [(port: 11300 | status: Unknown | lkt: 10/31/2023 6:34:10 PM),(port: 11000 | status: Unknown | lkt: 10/31/2023 6:34:10 PM),(port: 11300 | status: Unknown | lkt: 10/31/2023 6:34:10 PM),(port: 11300 | status: Unknown | lkt: 10/31/2023 6:34:10 PM)], TransportRequestTimeline: {"requestTimeline":[{"event": "Created", "startTimeUtc": "2023-11-06T03:10:09.2354919Z", "durationInMs": 0.0202},{"event": "ChannelAcquisitionStarted", "startTimeUtc": "2023-11-06T03:10:09.2355121Z", "durationInMs": 0.0029},{"event": "Pipelined", "startTimeUtc": "2023-11-06T03:10:09.2355150Z", "durationInMs": 0.0834},{"event": "Transit Time", "startTimeUtc": "2023-11-06T03:10:09.2355984Z", "durationInMs": 27.3781},{"event": "Received", "startTimeUtc": "2023-11-06T03:10:09.2629765Z", "durationInMs": 0.052},{"event": "Completed", "startTimeUtc": "2023-11-06T03:10:09.2630285Z", "durationInMs": 0}],"serviceEndpointStats":{"inflightRequests":1,"openConnections":1},"connectionStats":{"waitforConnectionInit":"False","callsPendingReceive":0,"lastSendAttempt":"2023-11-06T03:10:08.5389322Z","lastSend":"2023-11-06T03:10:08.5389710Z","lastReceive":"2023-11-06T03:10:08.5638294Z"},"requestSizeInBytes":465,"responseMetadataSizeInBytes":137,"responseBodySizeInBytes":87};\r\n ResourceType: Collection, OperationType: Read\r\nRequestStart: 2023-11-06T03:10:09.2356742Z; ResponseTime: 2023-11-06T03:10:09.2634136Z; StoreResult: StorePhysicalAddress: rntbd://10.0.1.10:11000/apps/540517c5-4054-412a-be16-72f3c4660990/services/d6b3ddae-1699-4df4-8552-05c7149c6c29/partitions/e6f134b0-8af5-4b53-bba8-53ad2c27780c/replicas/133074063057012226s, LSN: 3845, GlobalCommittedLsn: 3845, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#3845, UsingLocalLSN: False, TransportException: null, BELatencyMs: 26.377, ActivityId: a484f1c9-caeb-4ba2-b0db-9935ce310b4d, RetryAfterInMs: , ReplicaHealthStatuses: [(port: 11300 | status: Unknown | lkt: 10/31/2023 6:34:10 PM),(port: 11000 | status: Unknown | lkt: 10/31/2023 6:34:10 PM),(port: 11300 | status: Unknown | lkt: 10/31/2023 6:34:10 PM),(port: 11300 | status: Unknown | lkt: 10/31/2023 6:34:10 PM)], TransportRequestTimeline: {"requestTimeline":[{"event": "Created", "startTimeUtc": "2023-11-06T03:10:09.2356156Z", "durationInMs": 0.0055},{"event": "ChannelAcquisitionStarted", "startTimeUtc": "2023-11-06T03:10:09.2356211Z", "durationInMs": 0.0012},{"event": "Pipelined", "startTimeUtc": "2023-11-06T03:10:09.2356223Z", "durationInMs": 0.0462},{"event": "Transit Time", "startTimeUtc": "2023-11-06T03:10:09.2356685Z", "durationInMs": 26.8268},{"event": "Received", "startTimeUtc": "2023-11-06T03:10:09.2624953Z", "durationInMs": 0.0788},{"event": "Completed", "startTimeUtc": "2023-11-06T03:10:09.2625741Z", "durationInMs": 0}],"serviceEndpointStats":{"inflightRequests":1,"openConnections":1},"connectionStats":{"waitforConnectionInit":"False","callsPendingReceive":0,"lastSendAttempt":"2023-11-06T03:10:08.5390150Z","lastSend":"2023-11-06T03:10:08.5390292Z","lastReceive":"2023-11-06T03:10:08.5629103Z"},"requestSizeInBytes":465,"responseMetadataSizeInBytes":137,"responseBodySizeInBytes":87};\r\n ResourceType: Collection, OperationType: Read\r\n, SDK: Microsoft.Azure.Documents.Common/2.14.0, Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, Windows/10.0.17763 cosmos-netstandard-sdk/3.18.0"}}]}, Windows/10.0.17763 cosmos-netstandard-sdk/3.18.0
[2023-11-06T03:10:10.445Z] ActivityId: d8aa33cc-a2d9-4276-babf-2d7edd57495c, Windows/10.0.19045 documentdb-netcore-sdk/2.20.0.
The text was updated successfully, but these errors were encountered: