Skip to content

Commit 957ea65

Browse files
Feature/storage/transactional crc (Azure#23056)
* Transactional hashing models * StageBlock now has transactional hashing support * ContentHasher supports precalculated hash GetHash will now read all options and pull a possible precalculated hash into its response instead of calculating the result from scratch * New overloads appendblobclient and blockblobclient now have options bag overloads for their baseline upload methods. * Append and page blob updates Those clients now have new APIs for base uploads, deprecated old overloads, and updated writestreams to use the new internal signature. * Alligned XxxOpenWriteOptions for hashing options * Blob Write Streams Updated * uploadTransactionalHashing in datalake and shares * fixed mock issues Fixed how some mocks were constructed due to new signatures for some internal methods * blob download range transactional hashing * crc46 implementation and download tests * several read methods updated to transactional hash * testing * datalake/share download * build fix * renames | Blob/datalake downloadTo hashing * tests and fixes * Range required for download hashing testing, recording. * more tests. property renames for consistency. * Azure.Storage.Models => Azure.Storage Moved transactional hashing options classes down a namespace * fixes and rerecording transactional hashing tests * recording fix * recording * test fixes * all hashing tests scan messages for headers * minor fixes and test organization * test fine-tuning and rerecording * open write tests refactored for reusability * test refactors * More test refactoring * refactored parallel upload tests * finished blob test refactoring * exportapi * fix export * fixed a scope issue * fixed datalake.append scope and common mock * fixed mock setup * More mocking issues * irerecord * full rerecording transactional hash tests * revert force record mode * testing CI failure removing an inserted policy from hashing partitioned download tests to determine if it is interfering in recording interpretation. * Revert "testing CI failure" This reverts commit 4bbb8d3. * made encryption/hashing test liveonly * datalake transactional hashing tests * port hashing tests to file shares * transactional hash arg validation * parallel upload doesn't accept precalculated hash * rerecord transactional hashing tests * restored accidental recording delete * rerecorded OpenRead tests * rerecord misc file share tests * New storagecrc64 API shape storage crc calculator prepared to inherit NonCryptographicHashAlgorithm when released. Static crc calculator converted to use ReadOnlySpan<byte> instead of byte[]. Static crc calculator converted to use BinaryPrimitives instead of BitConverter. NOTE this forces the calculation into a specific endianness which is acceptable based on CRC properties. * exportapi * misc pr feedback * Fixed a docstring * fixed diagnostic scope issue * Documented TransactionalHashingTestSkeletons.cs * test comments * Some PR responses Some options classes renamed GetHashResult memory optimizations. Disabled clientside crypto/hashing in combination * new downloadto options have consistent API shape * datalake hashing tests now use hns tenant * More PR comments * export api * new options bag APIs memory optimization * fixed failed tests * Initial hashing test conversion Converted TransactionalHashingTestSkeletons (collection of static helper methods) to TransactionalHashingTestBase : StorageTestBase. Tests are fully defined on this class. Subclasses per-client will implement abstract methods as instructions for uploads/downloads/etc., where before they were lambdas passed to the static helper methods every single time. * moved transactional hashing tests under new inheritance tree * deleted old hashing test session records * fixed playback bug and rerecorded to accomodate * Recorded inconclusive hashing tests * more recording inconclusive tests * quick fix * nitpicks/cleanup * ported v11 crc test * file header * reverted some auto IDE csproj changes * corrected a formating reversion * pr feedback * arg validation * pr feedback * Changelog Co-authored-by: jschrepp-MSFT <41338290+jschrepp-MSFT@users.noreply.github.com>
1 parent 5db70e9 commit 957ea65

File tree

695 files changed

+100648
-31747
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

695 files changed

+100648
-31747
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Added support for Encryption Scope SAS.
66
- Added support for Encryption Scopes with BlobBaseClient.SyncCopyFromUriAsync().
77
- Added support for generating SAS URLs with the Permanent Delete ('y') SAS permission.
8+
- Added support for SDK-calculated transactional hash checksums on data transfer.
89
- Fixed bug where BlobContainerClient.GetBlobs() and .GetBlobsByHierarchyAsync() was not parsing the Object Replication Metadata correctly
910

1011
## 12.10.0 (2021-09-08)

sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs

Lines changed: 66 additions & 0 deletions
Large diffs are not rendered by default.

sdk/storage/Azure.Storage.Blobs/src/AppendBlobClient.cs

Lines changed: 175 additions & 66 deletions
Large diffs are not rendered by default.

sdk/storage/Azure.Storage.Blobs/src/AppendBlobWriteStream.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ public AppendBlobWriteStream(
2020
long bufferSize,
2121
long position,
2222
AppendBlobRequestConditions conditions,
23-
IProgress<long> progressHandler) : base(
23+
IProgress<long> progressHandler,
24+
UploadTransactionalHashingOptions hashingOptions) : base(
2425
position,
2526
bufferSize,
26-
progressHandler)
27+
progressHandler,
28+
hashingOptions)
2729
{
2830
ValidateBufferSize(bufferSize);
2931
_appendBlobClient = appendBlobClient;
@@ -40,9 +42,12 @@ protected override async Task AppendInternal(
4042

4143
Response<BlobAppendInfo> response = await _appendBlobClient.AppendBlockInternal(
4244
content: _buffer,
43-
transactionalContentHash: default,
44-
conditions: _conditions,
45-
progressHandler: _progressHandler,
45+
new AppendBlobAppendBlockOptions()
46+
{
47+
TransactionalHashingOptions = _hashingOptions,
48+
Conditions = _conditions,
49+
ProgressHandler = _progressHandler
50+
},
4651
async: async,
4752
cancellationToken: cancellationToken)
4853
.ConfigureAwait(false);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
44
</PropertyGroup>
@@ -48,11 +48,15 @@
4848
<Compile Include="$(AzureStorageSharedSources)ClientsideEncryption\Models\*.cs" LinkBase="Shared" />
4949
<Compile Include="$(AzureStorageSharedSources)AggregatingProgressIncrementer.cs" LinkBase="Shared" />
5050
<Compile Include="$(AzureStorageSharedSources)Constants.cs" LinkBase="Shared" />
51+
<Compile Include="$(AzureStorageSharedSources)ContentHasher.cs" LinkBase="Shared" />
5152
<Compile Include="$(AzureStorageSharedSources)Errors.cs" LinkBase="Shared" />
5253
<Compile Include="$(AzureStorageSharedSources)Errors.Clients.cs" LinkBase="Shared" />
5354
<Compile Include="$(AzureStorageSharedSources)GeoRedundantReadPolicy.cs" LinkBase="Shared" />
55+
<Compile Include="$(AzureStorageSharedSources)HashAlgorithmHasher.cs" LinkBase="Shared" />
5456
<Compile Include="$(AzureStorageSharedSources)IDownloadedContent.cs" LinkBase="Shared" />
57+
<Compile Include="$(AzureStorageSharedSources)IHasher.cs" LinkBase="Shared" />
5558
<Compile Include="$(AzureStorageSharedSources)LoggingExtensions.cs" LinkBase="Shared" />
59+
<Compile Include="$(AzureStorageSharedSources)NonCryptographicHashAlgorithmHasher.cs" LinkBase="Shared" />
5660
<Compile Include="$(AzureStorageSharedSources)NonDisposingStream.cs" LinkBase="Shared" />
5761
<Compile Include="$(AzureStorageSharedSources)PartitionedUploader.cs" LinkBase="Shared" />
5862
<Compile Include="$(AzureStorageSharedSources)PooledMemoryStream.cs" LinkBase="Shared" />

sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs

Lines changed: 509 additions & 78 deletions
Large diffs are not rendered by default.

sdk/storage/Azure.Storage.Blobs/src/BlobClient.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,13 +1624,19 @@ internal async Task<Response<BlobContentInfo>> StagedUploadInternal(
16241624
{
16251625
if (UsingClientSideEncryption)
16261626
{
1627+
if (UsingClientSideEncryption && options.TransactionalHashingOptions != default)
1628+
{
1629+
throw Errors.TransactionalHashingNotSupportedWithClientSideEncryption();
1630+
}
1631+
16271632
// content is now unseekable, so PartitionedUploader will be forced to do a buffered multipart upload
16281633
(content, options.Metadata) = await new BlobClientSideEncryptor(new ClientSideEncryptor(ClientSideEncryption))
16291634
.ClientSideEncryptInternal(content, options.Metadata, async, cancellationToken).ConfigureAwait(false);
16301635
}
16311636

16321637
var uploader = GetPartitionedUploader(
16331638
transferOptions: options?.TransferOptions ?? default,
1639+
options?.TransactionalHashingOptions,
16341640
operationName: $"{nameof(BlobClient)}.{nameof(Upload)}");
16351641

16361642
return await uploader.UploadInternal(
@@ -1724,8 +1730,9 @@ private BlockBlobClient BlockBlobClient
17241730

17251731
internal PartitionedUploader<BlobUploadOptions, BlobContentInfo> GetPartitionedUploader(
17261732
StorageTransferOptions transferOptions,
1733+
UploadTransactionalHashingOptions hashingOptions,
17271734
ArrayPool<byte> arrayPool = null,
17281735
string operationName = null)
1729-
=> BlockBlobClient.GetPartitionedUploader(transferOptions, arrayPool, operationName);
1736+
=> BlockBlobClient.GetPartitionedUploader(transferOptions, hashingOptions, arrayPool, operationName);
17301737
}
17311738
}

0 commit comments

Comments
 (0)