如何在没有大小限制异常的情况下将 append blob 上传到 azure?

How to upload append blob to azure without getting size limit exception?

public async Task<string> UploadDataAsync<T>(CloudBlobContainer container, string relativeUrl, List<T> reportData, string mimeType, string data, ILogger log)
    {
        string absoluteUri = string.Empty;
        byte[] bytes = Encoding.ASCII.GetBytes(data);
        using (var ms = new MemoryStream())
        {
            using (StreamWriter sw = new StreamWriter(ms))
            {
                sw.Write(data);
                sw.Flush();
                ms.Position = 0;

                CloudAppendBlob blob;
                blob = container.GetAppendBlobReference(relativeUrl);
                if (await blob.ExistsAsync())
                {
                    await blob.AppendBlockAsync(ms);
                    absoluteUri = blob.StorageUri.PrimaryUri.AbsoluteUri;
                }
                else
                {
                    CloudAppendBlob appBlob = await CreateEmptyFileAsync(container, relativeUrl, reportData, mimeType, log);
                    await appBlob.AppendBlockAsync(ms);
                    absoluteUri = appBlob.StorageUri.PrimaryUri.AbsoluteUri;
                }
            }
        }

        return absoluteUri;
    }

获取此异常 -

Microsoft.WindowsAzure.Storage.StorageException: 'The request body is too large and exceeds the maximum permissible limit.' [外部代码] PDCGeoTabFunction.Services.UploadService.UploadDataAsync(Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer, 字符串, System.Collections.Generic.List, 字符串, 字符串, Microsoft.Extensions.Logging.ILogger) 在 UploadService.cs [外部代码] PDCGeoTabFunction.Services.SyncGeoTabDataService.GetZone(Geotab.Checkmate.API, 字符串, 字符串, 字符串, Microsoft.Extensions.Logging.ILogger, 字符串, 字符串, 字符串, 字符串, System.Collections.Generic.List) 在 SyncGeoTabDataService.cs

请帮忙。

您收到此错误的原因很可能是因为您尝试上传的数据超过 4MB。每个附加操作的请求负载大小最大为 4MB。

来自REST API documentation

Append Block uploads a block to the end of an existing append blob. The block of data is immediately available once the call succeeds on the server. A block may be up to 4 MiB in size.

请以每次调用 AppendBlockAsync 上传的数据不超过 4MB 的方式拆分您的数据。