The offices change their appointments constantly: One person extends one, the head office adds notes, two devices send the same appointment because the network stalled. This lesson shows how Kladde.Verlauf writes into appointments without losing or duplicating anything.
Not run against Azure. The code was compiled with Microsoft.Azure.Cosmos 3.64.0 and Newtonsoft.Json 13.0.4. Only the loop for simultaneous changes was run, against a stand-in (Exercise 1). What is said about status codes, patch and TTL of the service comes from Microsoft Learn, read on the day of writing.
The four write operations
| Operation | Effect | Typical error |
|---|---|---|
CreateItemAsync |
creates | 409 if id and key are already taken |
UpsertItemAsync |
creates or replaces | – |
ReplaceItemAsync |
replaces the whole item | 404 if it is missing; 412 on a wrong ETag |
DeleteItemAsync |
deletes | 404 if it is already gone |
Replace and Upsert always write the whole item. According to Learn, the RU of a write grow with the size of the item, with the number of its properties and with the number of indexed paths (lesson 2.4). The status 413 comes when the item would be larger than 2 MB (K3, lesson 3.6.4); it is never retried.