![](/img/trans.png)
[英]How to calculate the total size of Blob storage containers in an storage account when using the new Azure.Storage.Blobs
[英]How do I set a retry policy on an Azure blob storage operation using the Azure.Storage.Blobs assembly?
使用(最新12.3.0在寫作的時候)的NuGet包為Azure.Storage.Blobs組裝和異步上傳與BlobServiceClient
類,我想在瞬時故障的情況下設定的重試選項。
但是UploadAsync()
方法的重載不接受任何帶有重試選項的對象:
UploadAsync(Stream, BlobHttpHeaders, IDictionary<String,String>, BlobRequestConditions, IProgress<Int64>, Nullable<AccessTier>, StorageTransferOptions, CancellationToken)
盡管在創建BlobServiceClient
,可以設置BlobClientOptions
,並且這些確實從抽象基類ClientOptions
繼承了RetryOptions
字段,但該字段是只讀的:
// Summary:
// Gets the client retry options.
public RetryOptions Retry { get; }
如何使用Azure.Storage.Blobs
程序集對 Azure blob 存儲操作設置重試策略?
創建 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);
此外,可以在創建BlobClientOptions
時設置BlobServiceClient
:
var blobServiceClient = new BlobServiceClient
(connectionString:storageAccountConnectionString, options: options );
然后,您可以使用BlobServiceClient.GetBlobContainerClient(blobContainerName:"")
和BlobContainerClient.GetBlobClient(blobName:"")
以一致的方式使用選項構建 blob URI。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.