Skip to content

Commit ad181aa

Browse files
[Storage][DataMovement] Fix large file transfers for certain destination types (Azure#48321)
1 parent 9332687 commit ad181aa

34 files changed

+198
-66
lines changed

sdk/storage/Azure.Storage.Common/src/Shared/Errors.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static ArgumentException InvalidService(char s)
4848
=> new ArgumentException($"Invalid service: '{s}'");
4949

5050
public static ArgumentException InsufficientStorageTransferOptions(long streamLength, long statedMaxBlockSize, long necessaryMinBlockSize)
51-
=> new ArgumentException($"Cannot upload {streamLength} bytes with a maximum transfer size of {statedMaxBlockSize} bytes per block. Please increase the StorageTransferOptions.MaximumTransferSize to at least {necessaryMinBlockSize}.");
51+
=> new ArgumentException($"Cannot transfer {streamLength} bytes with a maximum transfer size of {statedMaxBlockSize} bytes per block. Please increase the TransferOptions.MaximumTransferChunkSize to at least {necessaryMinBlockSize}.");
5252

5353
public static InvalidDataException HashMismatch(string hashHeaderName)
5454
=> new InvalidDataException($"{hashHeaderName} did not match hash of recieved data.");

sdk/storage/Azure.Storage.DataMovement.Blobs/CHANGELOG.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
# Release History
22

3-
## 12.1.0-beta.1 (Unreleased)
4-
5-
### Features Added
6-
7-
### Breaking Changes
3+
## 12.0.1 (Unreleased)
84

95
### Bugs Fixed
10-
11-
### Other Changes
6+
- Fixed an issue that would prevent transfers of large files (>200 GiB) for certain destination resource types.
127

138
## 12.0.0 (2025-02-11)
149

sdk/storage/Azure.Storage.DataMovement.Blobs/src/AppendBlobStorageResource.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ internal class AppendBlobStorageResource : StorageResourceItemInternal
3131

3232
protected override long MaxSupportedChunkSize => Constants.Blob.Append.MaxAppendBlockBytes;
3333

34+
protected override int MaxSupportedChunkCount => Constants.Blob.Append.MaxBlocks;
35+
3436
protected override long? Length => ResourceProperties?.ResourceLength;
3537

3638
internal AppendBlobStorageResource()

sdk/storage/Azure.Storage.DataMovement.Blobs/src/Azure.Storage.DataMovement.Blobs.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66
<PropertyGroup>
77
<AssemblyTitle>Microsoft Azure.Storage.DataMovement.Blobs client library</AssemblyTitle>
8-
<Version>12.1.0-beta.1</Version>
8+
<Version>12.0.1</Version>
99
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
1010
<ApiCompatVersion>12.0.0</ApiCompatVersion>
1111
<DefineConstants>BlobDataMovementSDK;$(DefineConstants)</DefineConstants>

sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlockBlobStorageResource.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ internal class BlockBlobStorageResource : StorageResourceItemInternal
4040

4141
protected override long MaxSupportedChunkSize => Constants.Blob.Block.MaxStageBytes;
4242

43+
protected override int MaxSupportedChunkCount => Constants.Blob.Block.MaxBlocks;
44+
4345
protected override long? Length => ResourceProperties?.ResourceLength;
4446

4547
/// <summary>

sdk/storage/Azure.Storage.DataMovement.Blobs/src/PageBlobStorageResource.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ internal class PageBlobStorageResource : StorageResourceItemInternal
3232

3333
protected override long MaxSupportedChunkSize => Constants.Blob.Page.MaxPageBlockBytes;
3434

35+
protected override int MaxSupportedChunkCount => int.MaxValue;
36+
3537
protected override long? Length => ResourceProperties?.ResourceLength;
3638

3739
public PageBlobStorageResource()

sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/AppendBlobDirectoryToShareDirectoryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected override async Task CreateObjectInSourceAsync(
4545
}
4646
else
4747
{
48-
var data = new byte[0];
48+
byte[] data = GetRandomBuffer(objectLength ?? 0);
4949
using (var stream = new MemoryStream(data))
5050
{
5151
await UploadAppendBlocksAsync(

sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/AppendBlobToShareFileTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class AppendBlobToShareFileTests : StartTransferCopyTestBase
4242
private const string _fileResourcePrefix = "test-file-";
4343
private const string _expectedOverwriteExceptionMessage = "Cannot overwrite file.";
4444
protected readonly object _serviceVersion;
45-
private const string _defaultContentType = "text/plain";
45+
private const string _defaultContentType = "image/jpeg";
4646
private readonly string[] _defaultContentLanguageFile = { "en-US" };
4747
private const string _defaultContentLanguageBlob = "en-US";
4848
private const string _defaultContentDisposition = "inline";
@@ -122,9 +122,11 @@ protected override async Task<AppendBlobClient> GetSourceObjectClientAsync(
122122
}
123123
else
124124
{
125-
var data = GetRandomBuffer(objectLength.Value);
126-
using Stream originalStream = await CreateLimitedMemoryStream(objectLength.Value);
127-
await UploadAppendBlocksAsync(blobClient, originalStream, cancellationToken);
125+
byte[] data = GetRandomBuffer(objectLength.Value);
126+
using (var stream = new MemoryStream(data))
127+
{
128+
await UploadAppendBlocksAsync(blobClient, stream, cancellationToken);
129+
}
128130
}
129131
}
130132
Uri sourceUri = blobClient.GenerateSasUri(Sas.BlobSasPermissions.All, Recording.UtcNow.AddDays(1));

sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/BlockBlobDirectoryToShareDirectoryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ await blobClient.UploadAsync(
5858
}
5959
else
6060
{
61-
var data = new byte[0];
61+
byte[] data = GetRandomBuffer(objectLength ?? 0);
6262
using (var stream = new MemoryStream(data))
6363
{
6464
await blobClient.UploadAsync(

sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/BlockBlobToShareFileTests.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class BlockBlobToShareFileTests : StartTransferCopyTestBase
3838
StorageTestEnvironment>
3939
{
4040
private readonly AccessTier _defaultAccessTier = AccessTier.Cold;
41-
private const string _defaultContentType = "text/plain";
41+
private const string _defaultContentType = "image/jpeg";
4242
private readonly string[] _defaultContentLanguageFile = { "en-US" };
4343
private const string _defaultContentLanguageBlob = "en-US";
4444
private const string _defaultContentDisposition = "inline";
@@ -136,10 +136,11 @@ await blobClient.UploadAsync(
136136
}
137137
else
138138
{
139-
var data = GetRandomBuffer(objectLength.Value);
140-
using Stream originalStream = await CreateLimitedMemoryStream(objectLength.Value);
141-
await blobClient.UploadAsync(
142-
content: originalStream,
139+
byte[] data = GetRandomBuffer(objectLength.Value);
140+
using (var stream = new MemoryStream(data))
141+
{
142+
await blobClient.UploadAsync(
143+
content: stream,
143144
new BlobUploadOptions()
144145
{
145146
AccessTier = _defaultAccessTier,
@@ -153,6 +154,7 @@ await blobClient.UploadAsync(
153154
}
154155
},
155156
cancellationToken: cancellationToken);
157+
}
156158
}
157159
}
158160
Uri sourceUri = blobClient.GenerateSasUri(Sas.BlobSasPermissions.All, Recording.UtcNow.AddDays(1));

0 commit comments

Comments
 (0)