Skip to content

Commit 29b7a3b

Browse files
yifanz7blueww
andauthored
[Storage] Support high throughput append blob (#23484)
* [Storage] Support append 100MB block * Update chunk size * Remove redundant line * Add in missing changelog items from previous releases --------- Co-authored-by: Wei Wei (AZURE) <[email protected]>
1 parent 0f7fcbf commit 29b7a3b

File tree

4 files changed

+80
-10
lines changed

4 files changed

+80
-10
lines changed

src/Storage/Storage.Management/ChangeLog.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Supported high throughput append blob
22+
- `Set-AzStorageBlobContent`
23+
- `Copy-AzStorageBlob`
2124

2225
## Version 6.0.0
2326
* Supported customer initiated migration
@@ -68,6 +71,12 @@
6871
- `New-AzStorageAccount`
6972
* Updated help file of `New-AzStorageQueueSASToken`
7073

74+
## Version 5.9.1
75+
* Added support for customer initiated account migration
76+
- `Start-AzStorageAccountMigration`
77+
- `Get-AzStorageAccountMigration`
78+
* Supported Storage account planned failover new properties
79+
- `Get-AzStorageAccount`
7180

7281
## Version 5.9.0
7382
* Supported OAuth authentication on File service cmdlets
@@ -145,6 +154,26 @@
145154
* Support get a file share object without get share properties. For pipeline to file/directory cmdlets with OAuth authentication.
146155
- `Get-AzStorageShare`
147156

157+
## Version 5.6.2
158+
* Removed the API version limitation on File cmdlets
159+
160+
## Version 5.6.1
161+
* Support OAuth authentication on File service cmdlets
162+
- `New-AzStorageContext`
163+
- `Get-AzStorageFile`
164+
- `Get-AzStorageFileContent`
165+
- `Get-AzStorageFileCopyState`
166+
- `New-AzStorageDirectory`
167+
- `Remove-AzStorageDirectory`
168+
- `Remove-AzStorageFile`
169+
- `Set-AzStorageFileContent`
170+
- `Start-AzStorageFileCopy`
171+
- `Stop-AzStorageFileCopy`
172+
- `Get-AzStorageFileHandle`
173+
- `Close-AzStorageFileHandle`
174+
* Support get a file share object without get share properties. For pipeline to file/directory cmdlets with OAuth authentication.
175+
- `Get-AzStorageShare`
176+
148177
## Version 5.6.0
149178
* Supported rename file and directory
150179
- `Rename-AzStorageFile`
@@ -204,6 +233,12 @@
204233
* Returned AllowedCopyScope in get account result
205234
- `Get-AzStorageAccount`
206235

236+
## Version 5.2.2
237+
* Supported Planned and Unplanned types in Storage account failover type
238+
- `Invoke-AzStorageAccountFailover`
239+
* Supported TierToCold and TierToHot in Storage account management policy
240+
- `Add-AzStorageAccountManagementPolicyAction`
241+
207242
## Version 5.2.0
208243
* Supported MaxPageSize, Include, and Filter parameters for listing encryption scopes
209244
- `Get-AzStorageEncryptionScope`

src/Storage/Storage/Blob/Cmdlet/CopyAzureStorageBlob.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,10 @@ private async Task CopyFromUri(long taskId, IStorageBlobManagement destChannel,
466466
long appendCopyOffset = 0;
467467
progressHandler.Report(appendCopyOffset);
468468
long appendContentLenLeft = srcProperties.ContentLength;
469+
long appendChunkSize = GetAppendBlockLength(srcProperties.ContentLength);
469470
while (appendContentLenLeft > 0)
470471
{
471-
long appendContentSize = appendContentLenLeft < size4MB ? appendContentLenLeft : size4MB;
472+
long appendContentSize = appendContentLenLeft < appendChunkSize ? appendContentLenLeft : appendChunkSize;
472473

473474
Track2Models.AppendBlobAppendBlockFromUriOptions appendBlobAppendBlockFromUriOptions = new Track2Models.AppendBlobAppendBlockFromUriOptions
474475
{

src/Storage/Storage/Blob/Cmdlet/SetAzureStorageBlobContent.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ protected override void DoEndProcessing()
394394
Tuple<string, StorageBlob.CloudBlob> uploadRequest = UploadRequests.DequeueRequest();
395395
IStorageBlobManagement localChannel = Channel;
396396
Func<long, Task> taskGenerator;
397-
if (!UseTrack2Sdk())
397+
long fileSize = new FileInfo(ResolvedFileName).Length;
398+
399+
if (!UseTrack2Sdk() && (this.BlobType.ToLower() != AppendBlobType.ToLower() || fileSize <= (long)size4MB * maxBlockCount))
398400
{
399401
//Upload with DMlib
400402
taskGenerator = (taskId) => Upload2Blob(taskId, localChannel, uploadRequest.Item1, uploadRequest.Item2);
@@ -542,32 +544,39 @@ internal virtual async Task UploadBlobwithSdk(long taskId, IStorageBlobManagemen
542544
}
543545

544546
// Upload blob content
545-
byte[] uploadcache4MB = null;
547+
//For page blob will always use 4MB
548+
long chunksize = size4MB;
549+
550+
// for append blob, the chunksize can be at most 100MB, will make it multiple of 8MB.
551+
if (string.Equals(blobType, AppendBlobType, StringComparison.InvariantCultureIgnoreCase))
552+
{
553+
chunksize = GetAppendBlockLength(fileSize);
554+
}
555+
byte[] uploadcacheLong = null;
546556
byte[] uploadcache = null;
547557
progressHandler.Report(0);
548558
long offset = 0;
549559
while (offset < fileSize)
550560
{
551561
// Get chunk size and prepare cache
552-
int chunksize = size4MB;
553562
if (chunksize <= (fileSize - offset)) // Chunk size will be 4MB
554563
{
555-
if (uploadcache4MB == null)
564+
if (uploadcacheLong == null)
556565
{
557-
uploadcache4MB = new byte[size4MB];
566+
uploadcacheLong = new byte[chunksize];
558567
}
559-
uploadcache = uploadcache4MB;
568+
uploadcache = uploadcacheLong;
560569
}
561570
else // last chunk can < 4MB
562571
{
563572
chunksize = (int)(fileSize - offset);
564-
if (uploadcache4MB == null)
573+
if (uploadcacheLong == null)
565574
{
566575
uploadcache = new byte[chunksize];
567576
}
568577
else
569578
{
570-
uploadcache = uploadcache4MB;
579+
uploadcache = uploadcacheLong;
571580
}
572581
}
573582

src/Storage/Storage/Blob/StorageDataMovementCmdletBase.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public class StorageDataMovementCmdletBase : StorageCloudBlobCmdletBase, IDispos
3232

3333
protected const int size256MB = 256 * 1024 * 1024;
3434

35+
protected const int maxBlockCount = 50000;
36+
37+
protected const int maxBlockSize = 100 * 1024 * 1024;
38+
3539
/// <summary>
3640
/// block blob type
3741
/// </summary>
@@ -189,14 +193,35 @@ public static long GetBlockLength(long contentLength)
189193
{
190194
return contentLength;
191195
}
192-
long blockLength = contentLength / 50000;
196+
long blockLength = contentLength / maxBlockCount;
193197
if (blockLength % (size8MB) != 0)
194198
{
195199
blockLength = (blockLength / (size8MB) + 1) * (size8MB);
196200
}
197201
return blockLength > 0 ? blockLength : contentLength;
198202
}
199203

204+
/// <summary>
205+
/// Get the block size from append blob length
206+
/// </summary>
207+
public static long GetAppendBlockLength(long contentLength)
208+
{
209+
if (contentLength <= size8MB)
210+
{
211+
return contentLength;
212+
}
213+
long blockLength = contentLength / maxBlockCount;
214+
if (blockLength <= size8MB)
215+
{
216+
return size8MB;
217+
}
218+
if (blockLength % (size4MB) != 0)
219+
{
220+
blockLength = (blockLength / (size4MB) + 1) * (size4MB);
221+
}
222+
return blockLength;
223+
}
224+
200225
/// <summary>
201226
/// Get the block id arrary from block blob length, block size and blob name
202227
/// </summary>

0 commit comments

Comments
 (0)