Mid Azure

How do you optimize performance for Cosmos DB in a .NET app?

  • Choose appropriate partition key
  • Use asynchronous SDK methods
  • Enable RU-based throughput scaling
  • Cache frequently accessed data using Redis Cache
  • Example in .NET SDK:

var container = cosmosClient.GetContainer("db", "container");

var query = new QueryDefinition("SELECT * FROM c WHERE c.status =

@status")

.WithParameter("@status", "Active");

var iterator = container.GetItemQueryIterator<MyItem>(query);

More from Microsoft Azure Tutorial

All questions for this course