Q32 Cosmos DB Domain 2 · 25–30% of exam

A Cosmos DB item was read with an ETag. How do you implement optimistic concurrency control?

  1. A Use a stored procedure
  2. B Use If-Match header with the ETag on the update request (correct answer)
  3. C Use partition key locking
  4. D Use transaction batch with read-first

Shortcut: Cosmos DB supports optimistic concurrency via ETags. Include the If-Match header with the item's ETag on updates; if the item was modified since, Cosmos DB returns 412 Precondition Failed.