How can you change the member names of an existing application?
If you have an existing application with C# member names that you cannot change, property attributes is a way to reuse types without incurring the risk of changing your existing code in significant ways or incurring technical debt.
Which method is used to create an item?
We can asynchronously call the CreateItemAsync<> method to create an item, however, this will not create metadata about the result of the operation. The result can then be stored in variable of type ItemResponse<>.
How can we handle exceptions, when creating documents or items ?
You can handle the CosmosException type which includes a StatusCode property for HTTP status code values.
Explain the meaning of the following HTTP codes –
400 – Bad request – This means that something was wrong with the item in the body of the request
403- Forbidden – the container is likely full
409 – Conflict – Item in container likely already having the same id
413 – RequestEntityTooLarge – Items exceeds max entity size
429 – Too Many Request – Current request exceeds the maximum RU/s provisioned for the container.
How can we read an item?
To read an item, we use the ReadItemAsync<> method, and need the following two things –
- unique id of the item
- we need to create a variable of type PartitionKey with the string value at the partition key path for the item we are seeking.
We can then access properties of the saddle variable and print them to console.
How can we change values of an item?
We can do this using the saddle properties and then invoke the UpsertItemAsync<> method. This can also be used to update the ttl of the item.
How can we delete the item?
To delete the item, invoke the DeleteItemAsync<> method, by passing the id and the partitionkeyvalue.
What parameter[s] are required to read an item in Azure Cosmos DB for NoSQL?
both Id and partition key value
Which method should you use to update an item in Azure Cosmos DB for NoSQL using the .NET SDK?
UpsertItemAsync<>
Which class contains the methods for Create, Read, Update, and Delete point operations on items in Azure Cosmos DB for NoSQL?
Container
How can we perform transactional operations like creating two items?
The Microsoft.Azure.Cosmos.Container class has a CreateTransactionalBatch member method that will create a new instance of type TransactionalBatch. Then we use the CreateItem to create new items.
Can two items with different logical partitions be create in the same transactional batch?
No. The transactional batch supports operations with the same logical partition key. Operations with different logical partition keys will fail.
Which method is used to execute a transactional batch?
ExecuteAsync method
Explain the following methods of the transactional batch –
CreateItemStream() – Create item from an existing stream
DeleteItem() – Delte an item
ReadItem()- Reads an item
ReplaceItem() or ReplaceItemStream() – Update an existing item or stream
UpsertItem() or UpsertItemStream() – Create or update an existing item or stream based on the item’s unique identifier.
How can we interrogate the results of an transaction?
The TransactionalBatchResponse class contains multiple members to interrogate results of the batch operation. The StatusCode property if of type HttpStatusCode and will return and HTTP status code .
What methods are used to check the transaction results?
The IsSuccessStatusCode property is a boolean property that you can use directly in your application code before extracting results.
The GetOperationResultAtIndex<> generic method returns the individual deserialized item at the index you specify.
How can concurrency be reached when performing read and write operations simultaneously on an item?
Each item has an ETag value. This value is updated when the item is updated. Using this value, lostupdates can be prevented.
What method parameters are required to create a transaction batch using container.CreateTransactionBatch()?
The CreateTransactionBatch() method has a single parameter of partition key.
You are using the ItemRequestOptions class to configure a request to enable optimistic concurrency control. Which header should you use to check for an exact value of an _etag?
IfMatchETag
You are using the ItemRequestOptions class to configure a request to enable optimistic concurrency control. Which header should you use to check for an exact value of an _etag?
StatusCode
Which class is used to create Bulk Operations?
CosmosClientOptions
Which setting of the CosmosClientOptions is used to allow bulk operations?
AllowBulkExecution
How is bulk operation executed?
We invoke the CreateItemAsync method which returns a Task , which in turn is immediately invoked using the await method, so we never really handle the Task object.
how is the bulk operation called?
Task.WhenAll(concurrentTask)
What is the document size created by SDK for bulk operations?
The SDK automatically creates batches for optimization with a mazimum of 2 MB or 100 operations. Smaller items can take advantage of this, with oversized items have an inverse effect.
Which property of the CosmosClientOptions class enables the ability to run multiple operations concurrently and transparently at scale?
AllowBulkExecution
Which property of the CosmosClientOptions class enables the ability to run multiple operations concurrently and transparently at scale?
Configure the partition key for each operation configured in a set of tasks.
What are the best practices for bulk operations?
- Configure the partition key
- Avoid unncessary serialization and deserialization. With Azure Cosmos DB for NoSQL, you can use the stream variants of common item operations to avoid unncessary performance overhead.
- Configure worker tasks per partition key.
Foolishly Yours,
Avantika Tanubhrt
Happy Learning 🙂

Leave a comment