如何使用Azure.Storage.Blobs程序集对Azure blob存储操作设置重试策略?

问题描述 投票:0回答:1

12.3.0程序集使用最新的(在编写时为NugetAzure.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存储操作上设置重试策略?

c# azure .net-core azure-storage-blobs
1个回答
1
投票
创建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);

© www.soinside.com 2019 - 2024. All rights reserved.