I was wondering if there is way or even if this would work: Upload a file to Azure blob storage inside a TransactionScope, and if anything goes wrong, rollback by 'deleting' the file.
Has anybody tried or achieved such objective?
Just an example of code that I am trying to accomplish:
using (var transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted }))
{
try {
//some code before to get the file from its location....
UploadFileToAzure(stream, filePath);
transaction.Complete();
}
catch(Exception ex)
{
//rollback the transaction and avoid uploading the file.
}
}