C#Azure存储的Blob上传的TransactionScope [英] C# Azure Storage Blob Upload TransactionScope

查看:268
本文介绍了C#Azure存储的Blob上传的TransactionScope的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

某处有一类允许回滚与蔚蓝blockblob行动的TransactionScope

Is there somewhere a class to allow roll back with transactionscope on azure blockblob actions ?

我想使这个作品:

  CloudBlockBlob blockBlob;

    private void UploadPicture(Stream iStream)
    {
        using(var ts = new TransactionScope())
        {
            blockBlob.UploadFromStream(iStream);

            throw new Exception();
            ts.Complete();
        }
    }

当异常是提高,上传的文件是不是取消。如果是不可能的事务范围,应该怎么处理?

When the exception is raise, the uploaded file is not cancelled. If is not possible with transaction scope, how should I proceed ?

推荐答案

Azure存储客户端库不提供这种支持。但是,如果取消的支持是可以接受你的方案,您可以使用 UploadFromStreamAsync API与的CancellationToken 。虽然它是异步上传一滴,就可以取消该操作。根据不同的操作目前的进展,它会尝试中止上传

Azure Storage Client Library does not provide this support. If, however, cancellation support is acceptable for your scenario, you can use the UploadFromStreamAsync API with a CancellationToken. While it is asynchronously uploading the blob, you can cancel the operation. Depending on the operation's current progress, it will try to abort the upload.

这篇关于C#Azure存储的Blob上传的TransactionScope的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆