簡體   English   中英

Azure blob存儲 api 上傳大文件時不支持Blob操作

[英]Azure blob storage api returns Blob operation is not supported when uploading large files

我的 azure function 從一個存儲賬戶讀取 zip 文件,解壓到另一個存儲賬戶。

對於大文件,它會拋出錯誤的所有詳細信息:

System.AggregateException: One or more errors occurred. (One or more errors occurred. (Blob operation is not supported.)) ---> 
System.AggregateException: One or more errors occurred. (Blob operation is not supported.) ---> 
Microsoft.WindowsAzure.Storage.StorageException: Blob operation is not supported.     
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteAsyncInternal[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext, CancellationToken token)    
at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.PutBlockAsync(String blockId, Stream blockData, String contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AggregatingProgressIncrementer progressIncrementer, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.Storage.Blob.BlobWriteStream.FlushAsync(CancellationToken cancellationToken)
at Microsoft.WindowsAzure.Storage.Blob.BlobWriteStream.CommitAsync()   
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.WindowsAzure.Storage.Blob.BlobWriteStream.<Dispose>b__8_0()  at Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility.RunWithoutSynchronizationContext(Action actionToRun)
at Microsoft.WindowsAzure.Storage.Blob.BlobWriteStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.Stream.Dispose()
at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.UploadFromStreamAsyncHelper(Stream source, Nullable`1 length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, IProgress`1 progressHandler, CancellationToken cancellationToken)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.UploadFromFileAsync(String path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, IProgress`1 progressHandler, CancellationToken cancellationToken)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.UploadFromFileAsync(String path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
at PipelineTriggers.PreprocessingFunctions.WaxTriggersFromBlob(CloudBlockBlob myBlob, String name, ILogger log, ExecutionContext context) in D:\a\1\s\Development\PipelineTriggers\PipelineTriggers\PreprocessingFunctions.cs:line 94---> (Inner Exception #0) 
System.AggregateException: One or more errors occurred. (Blob operation is not supported.) ---> Microsoft.WindowsAzure.Storage.StorageException: Blob operation is not supported.
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteAsyncInternal[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext, CancellationToken token)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.PutBlockAsync(String blockId, Stream blockData, String contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AggregatingProgressIncrementer progressIncrementer, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.Storage.Blob.BlobWriteStream.FlushAsync(CancellationToken cancellationToken)
at Microsoft.WindowsAzure.Storage.Blob.BlobWriteStream.CommitAsync() ---> (Inner Exception #0) 
Microsoft.WindowsAzure.Storage.StorageException: Blob operation is not supported.
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteAsyncInternal[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext, CancellationToken token)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.PutBlockAsync(String blockId, Stream blockData, String contentMD5, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AggregatingProgressIncrementer progressIncrementer, CancellationToken cancellationToken)
Request Information
  RequestID:b35c121a-c01e-005d-1c38-90d752000000
  RequestDate:Mon, 21 Sep 2020 16:57:10 GMT
  StatusMessage:Blob operation is not supported. 
  ErrorCode:BlobOperationNotSupported
  ErrorMessage:Blob operation is not supported.
  RequestId:b35c121a-c01e-005d-1c38-90d752000000
  Time:2020-09-21T16:57:10.0072501Z <--- <---

這是代碼:

foreach (var file in zip.Entries)
{
    log.LogInformation($"Processing file: {file.Name}");
    CloudBlockBlob blockBlob = container.GetBlockBlobReference(targetFolderName + "/" + file.Name);
    blockBlob.Properties.ContentType = "text/csv";
    await blockBlob.UploadFromStreamAsync(file.Open());
}

是什么原因導致這個問題,我該如何解決?

由於我不知道你的文件大小,這里有一些建議給你。

Microsoft 文檔中說上傳塊 blob 時存在限制:

存儲客戶端默認最大單個 blob 上傳為 128 MiB,可在 Azure 存儲客戶端庫中設置 .NET 版本 11,方法是使用 BlobRequestOptions object 的 SingleBlobUploadThresholdInBytes 屬性。當塊 blob 上傳大於此屬性中的值時,存儲客戶端會中斷文件分成塊。

一個塊 blob 最多可以包含 50,000 個塊。

您可以使用Put Blob編寫一組塊來上傳您的文件,但也有一個限制:

通過 Put Blob 創建的塊 blob 的最大大小對於 2016-05-31 及更高版本為 256 MiB,對於舊版本為 64 MiB。 如果 2016-05-31 及更高版本的 blob 大於 256 MiB,或舊版本大於 64 MiB,則必須將其作為一組塊上傳。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM