[FEATURE REQ] Introduce a response object for Add, Update, and Upsert entity methods
See original GitHub issueLibrary or service name. Azure.Data.Tables
Is your feature request related to a problem? Please describe.
This response object would be called something like “EntityUpdateInfo” and would have at least an ETag
property but in the future could contain a property with the whole T
entity if the Prefer: return-content
header is able to be specified as a parameter (don’t know if there’s plans to support this).
When using Azure.Data.Tables to insert, update, or upsert a record to a table, it’s important to have the latest etag returned in the response headers to continue a chain of operations based on optimistic concurrency. If the etag is not surfaced in the API you must either:
- Tease the
ETag
out of the returnedResponse.Headers.ETag.Value
(not terrible, but not ideal) - Query the entity again (UNSAFE, the entity may have been changed!)
As a nice to have, it would be great if the a Timestamp
was included as well on this new response type, which is what WindowsAzure.Storage
does by parsing the etag (perhaps a bad idea, especially if the behavior is different on Cosmos DB). I can’t find the source of WindowsAzure.Storage
but if you decompile it with ILSpy there is a ParseETagForTimestamp
method much like this Java one:
https://github.com/Azure/azure-storage-android/blob/2c643c37c6b8c9081058add284c601a2393afc93/microsoft-azure-storage/src/com/microsoft/azure/storage/table/TableResult.java#L168-L180
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
As an aside, I’m a huge fan of Azure Table Storage (cheap+simple+fast) so I’m quite passionate about this new Azure.Data.Tables SDK. I am moving my side project over to the new SDK one module at a time and will be opening issues/PRs as I come upon things.
Thank you for the detailed and thoughtful feedback!
The dilemma here is that by default, we do not echo the entity in the response for these operations. So if we did return a model type, it would need to be something that is just the
ETag
. Other than returning the whole entity, which seems like it would be inefficient in the main line case, I’m not sure if it would make sense to create a model containing just theETag
.When calling
UpdateEntity
, the ETag value is required. We’ll throw if it is a default value, and unless it is set to “*”, it will never be treated as an unconditional update.OK, interesting. Yes, I think I prefer having the operations not affect the supplied entity. Updating just the
ETag
seems inconsistent, and updating the whole entity makes some assumptions that the object is not being used again for something else by the caller.