12.3.0程序集使用最新的(在编写时为Nuget)Azure.Storage.Blobs程序包,并与BlobServiceClient
类异步上传,我想在发生瞬时故障的情况下设置重试选项。
但是overload方法的UploadAsync()
都不带任何带有重试选项的对象:
UploadAsync(Stream, BlobHttpHeaders, IDictionary<String,String>, BlobRequestConditions, IProgress<Int64>, Nullable<AccessTier>, StorageTransferOptions, CancellationToken)
尽管创建BlobServiceClient
时可以设置BlobClientOptions
,并且它们确实从抽象基类RetryOptions
继承了ClientOptions
字段,但此字段是只读的:
// Summary:
// Gets the client retry options.
public RetryOptions Retry { get; }
如何使用Azure.Storage.Blobs
程序集在Azure Blob存储操作上设置重试策略?
var options = new BlobClientOptions();
options.Diagnostics.IsLoggingEnabled = false;
options.Diagnostics.IsTelemetryEnabled = false;
options.Diagnostics.IsDistributedTracingEnabled = false;
options.Retry.MaxRetries = 0;
var client = new BlobClient(blobUri: new Uri(uriString:""), options: options);