Closed ciacco85 closed 2 weeks ago
Are you able to query using the Cosmos SDK directly?
Not related, but you should move out the credential instance when configuring the context:
var credential = new DefaultAzureCredential();
services.AddDbContext<EFSNoSqlDbContext>(options => options.UseCosmos(
cosmosConfigs.AccountEndpoint, credential, cosmosConfigs.DatabaseName));
Honestly I have never used the Cosmos SDK directly, however with your suggestion the issue has not been solved. Any other idea? @AndriySvyryd
Honestly I have never used the Cosmos SDK directly, however with your suggestion the issue has not been solved.
What was the result of using it directly? Did it work?
@AndriySvyryd In the services registration pipeline of our startup
services.AddNosqlDbContexts(configuration, cosmosConfigSection)
.Configure<CosmosConfigs>(configuration.GetSection(cosmosConfigSection))
.RegisterNosqlRepository()
.EnsureMigrationOfNoSqlContext<EFSNoSqlDbContext>();
we essentially register DB context, register repositories and ensure the creation of the DB
var sp = services.BuildServiceProvider();
using (var context = sp.GetService<T>())
{
if (forceDelete)
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
}
The problem was that the built-in role Cosmos DB Built-in Data Contributor
cannot perform this operation, but exception was hidden during startup operation (my bad) and not logged inside Log Stream nor Application Insight
The problem was that the built-in role Cosmos DB Built-in Data Contributor cannot perform this operation, but exception was hidden during startup operation (my bad) and not logged inside Log Stream nor Application Insight
Right. Also, Cosmos SDK (used by EF) can't perform configuration operations using RBAC, you'd have to perform them using the ARM SDK or via portal.
Ask a question
I've followed these docs Authenticate .NET apps to Azure services during local development using developer accounts Use system-assigned managed identities to access Azure Cosmos DB data Inspected #26573, #26491 and #26491
Steps done
1 - Added the Cosmos DB Built-in Data Contributor to my identity for local debuging and to Azure resource with the following PS script
2 - Execute my example Console APP using the following DI registration
3 - Execute a simple query command
Stack trace
Version
EF Core version: 8.0.7 Database provider: CosmosDB Target framework: .NET 8.0) Operating system: