Open FabLuke opened 7 months ago
@FabLuke do you also get an exception if you create the credential outside of the lambda?
var credential = new DefaultAzureCredential();
services.AddDbContext<CosmosDbContext>((options) =>
{
options.UseCosmos(cosmosDbEndpoint, credential, "db");
});
We normally using managed identities to access cosmos db with ef core.
The error occurs in an azure function app running on an appservice(P2v3). We have a servicebus batch trigger, which is inserting data. After a while the attached exception occurs and can be only fixed with a function restart.
I isolated the error to the managed identity access, cause when i change the authentication to connection string, it is working. For a moment we can use the connection string, but we want to change back to managed identity.
I create a simple app and i can reproduced it to, so i will insert just the service registration. We inject the CosmosDbContext in a scoped service.
The registration which create the exception:
The registration which not create the exception:
stack traces
Include provider and version information
EF Core version: 8.0.2 Database provider: Microsoft.EntityFrameworkCore.Cosmos Target framework: NET 8.*)