Jun 03 2020 07:33 AM
I have noticed Azure has released transactional support across CosmosDB collections
https://devblogs.microsoft.com/cosmosdb/introducing-transactionalbatch-in-the-net-sdk/
Is the same available in the Python SDK? How about via Python Azure functions and function bindings?
Jun 16 2020 12:59 PM
@Val26 Hi there! Thanks for your great question. Unfortunately, I don't know the exact answer to this question, but I would recommend asking your question over at our Azure Functions Q&A resource. We're directing people to this location, as it is frequently monitored by a host of very helpful people who may have the answers you are looking for. :)
Sorry for not being able to help you further on this particular topic.
Thanks!
Skyler.
Jun 17 2020 04:12 AM
@skylerhartle , thx, actually I have figured it out what seems to be a good solution. If I write the whole list, at once, to func.DocumentList, like
async def upsert_posts(social_feed_writer, live_messages) -> List[Post]:
db_updates = func.DocumentList()
post_id= str(uuid.uuid4())
for live_message in live_messages:
#some data conversion stuff here
post_from_live_message = live_message_to_post_dict(live_message, post_id)
post = Post.build_model(post_from_live_message)
post_data = post.to_data() #makes a hash
#here is appends a func.Document to me func.DocumentList
db_updates.append(func.Document.from_dict(post_data))
social_feed_writer.set(db_updates)
....
Here socialFeedWriter is
CosmosDB binding in my Azure function seems to magically maintain a transaction, i.e. if one my entries fails, the rest will fail too
Jun 17 2020 09:13 AM
@Val26 I'm glad you managed to figure out the problem, and thanks for posting the solution here for others to see.