BlockBlobClient
The BlockBlobClient allows you to manipulate Azure
Storage block blobs.
Block blobs let you upload large blobs efficiently. Block blobs are
comprised of blocks, each of which is identified by a block ID. You
create or modify a block blob by writing a set of blocks and
committing them by their block IDs. Each block can be a different
size, up to a maximum of 4,000 MB (100 MB for requests using REST
versions before 2019-12-12 and 4 MB for requests using REST versions
before 2016-05-31), and a block blob can include up to 50,000 blocks.
The maximum size of a block blob is therefore approximately 190.73 TiB
(4,000 MB X 50,000 blocks). If you are writing a block blob that is
no more than 5,000 MB in size, you can upload it in its entirety with a
single write operation; see UploadAsync.
When you upload a block to a blob in your storage account, it is
associated with the specified block blob, but it does not become part
of the blob until you commit a list of blocks that includes the new
block's ID. New blocks remain in an uncommitted state until they are
specifically committed or discarded. Writing a block does not update
the last modified time of an existing blob.
Block blobs include features that help you manage large files over
networks. With a block blob, you can upload multiple blocks in
parallel to decrease upload time. Each block can include an MD5 hash
to verify the transfer, so you can track upload progress and re-send
blocks as needed.You can upload blocks in any order, and determine
their sequence in the final block list commitment step. You can also
upload a new block to replace an existing uncommitted block of the
same block ID. You have one week to commit blocks to a blob before
they are discarded. All uncommitted blocks are also discarded when a
block list commitment operation occurs but does not include them.
You can modify an existing block blob by inserting, replacing, or
deleting existing blocks. After uploading the block or blocks that
have changed, you can commit a new version of the blob by committing
the new blocks with the existing blocks you want to keep using a
single commit operation. To insert the same range of bytes in two
different locations of the committed blob, you can commit the same
block in two places within the same commit operation.For any commit
operation, if any block is not found, the entire commitment operation
fails with an error, and the blob is not modified. Any block commitment
overwrites the blob’s existing properties and metadata, and discards
all uncommitted blocks.
Block IDs are strings of equal length within a blob. Block client code
usually uses base-64 encoding to normalize strings into equal lengths.
When using base-64 encoding, the pre-encoded string must be 64 bytes
or less. Block ID values can be duplicated in different blobs. A
blob can have up to 100,000 uncommitted blocks, with a max total size
of appoximately 381.46 TiB (4,000 MB x 100,000 blocks)
If you write a block for a blob that does not exist, a new block blob
is created, with a length of zero bytes. This blob will appear in
blob lists that include uncommitted blobs. If you don’t commit any
block to this blob, it and its uncommitted blocks will be discarded
one week after the last successful block upload. All uncommitted
blocks are also discarded when a new blob of the same name is created
using a single step(rather than the two-step block upload-then-commit
process).
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Storage.Blobs.Models;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace Azure.Storage.Blobs.Specialized
{
public class BlockBlobClient : BlobBaseClient
{
private readonly BlockBlobRestClient _blockBlobRestClient;
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual int BlockBlobMaxUploadBlobBytes {
get {
if (ClientConfiguration.Version >= BlobClientOptions.ServiceVersion.V2019_12_12)
return 2147483647;
return 268435456;
}
}
public virtual long BlockBlobMaxUploadBlobLongBytes {
get {
if (ClientConfiguration.Version >= BlobClientOptions.ServiceVersion.V2019_12_12)
return 5242880000;
return 268435456;
}
}
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual int BlockBlobMaxStageBlockBytes {
get {
if (ClientConfiguration.Version >= BlobClientOptions.ServiceVersion.V2019_12_12)
return 2147483647;
return 104857600;
}
}
public virtual long BlockBlobMaxStageBlockLongBytes {
get {
if (ClientConfiguration.Version >= BlobClientOptions.ServiceVersion.V2019_12_12)
return 4194304000;
return 104857600;
}
}
public virtual int BlockBlobMaxBlocks => 50000;
internal virtual BlockBlobRestClient BlockBlobRestClient => _blockBlobRestClient;
protected BlockBlobClient()
{
}
public BlockBlobClient(string connectionString, string containerName, string blobName)
: base(connectionString, containerName, blobName)
{
_blockBlobRestClient = BuildBlockBlobRestClient(_uri);
}
public BlockBlobClient(string connectionString, string blobContainerName, string blobName, BlobClientOptions options)
: base(connectionString, blobContainerName, blobName, options)
{
_blockBlobRestClient = BuildBlockBlobRestClient(_uri);
AssertNoClientSideEncryption(options);
}
public BlockBlobClient(Uri blobUri, BlobClientOptions options = null)
: base(blobUri, options)
{
_blockBlobRestClient = BuildBlockBlobRestClient(blobUri);
AssertNoClientSideEncryption(options);
}
public BlockBlobClient(Uri blobUri, StorageSharedKeyCredential credential, BlobClientOptions options = null)
: base(blobUri, credential, options)
{
_blockBlobRestClient = BuildBlockBlobRestClient(blobUri);
AssertNoClientSideEncryption(options);
}
public BlockBlobClient(Uri blobUri, AzureSasCredential credential, BlobClientOptions options = null)
: base(blobUri, credential, options)
{
_blockBlobRestClient = BuildBlockBlobRestClient(blobUri);
AssertNoClientSideEncryption(options);
}
public BlockBlobClient(Uri blobUri, TokenCredential credential, BlobClientOptions options = null)
: base(blobUri, credential, options)
{
_blockBlobRestClient = BuildBlockBlobRestClient(blobUri);
AssertNoClientSideEncryption(options);
}
internal BlockBlobClient(Uri blobUri, BlobClientConfiguration clientConfiguration)
: base(blobUri, clientConfiguration, null)
{
_blockBlobRestClient = BuildBlockBlobRestClient(blobUri);
}
internal BlockBlobClient(Uri blobUri, BlobClientConfiguration clientConfiguration, ClientSideEncryptionOptions clientSideEncryption)
: base(blobUri, clientConfiguration, clientSideEncryption)
{
_blockBlobRestClient = BuildBlockBlobRestClient(blobUri);
}
protected static BlockBlobClient CreateClient(Uri blobUri, BlobClientOptions options, HttpPipeline pipeline)
{
return new BlockBlobClient(blobUri, new BlobClientConfiguration(pipeline, null, new Azure.Core.Pipeline.ClientDiagnostics(options, null), options.Version, options.CustomerProvidedKey, options.TransferValidation, (string)null, options.TrimBlobNameSlashes));
}
private static void AssertNoClientSideEncryption(BlobClientOptions options)
{
if (options?._clientSideEncryptionOptions != null)
throw Errors.ClientSideEncryption.TypeNotSupported(typeof(BlockBlobClient));
}
private BlockBlobRestClient BuildBlockBlobRestClient(Uri blobUri)
{
return new BlockBlobRestClient(_clientConfiguration.ClientDiagnostics, _clientConfiguration.Pipeline, blobUri.AbsoluteUri, _clientConfiguration.Version.ToVersionString());
}
public new BlockBlobClient WithSnapshot(string snapshot)
{
return (BlockBlobClient)WithSnapshotCore(snapshot);
}
public new BlockBlobClient WithVersion(string versionId)
{
return new BlockBlobClient(new BlobUriBuilder(Uri) {
VersionId = versionId
}.ToUri(), ClientConfiguration);
}
protected sealed override BlobBaseClient WithSnapshotCore(string snapshot)
{
return new BlockBlobClient(new BlobUriBuilder(Uri) {
Snapshot = snapshot
}.ToUri(), ClientConfiguration);
}
public new BlockBlobClient WithCustomerProvidedKey(CustomerProvidedKey? customerProvidedKey)
{
BlobClientConfiguration blobClientConfiguration = BlobClientConfiguration.DeepCopy(ClientConfiguration);
blobClientConfiguration.CustomerProvidedKey = customerProvidedKey;
return new BlockBlobClient(Uri, blobClientConfiguration);
}
public new BlockBlobClient WithEncryptionScope(string encryptionScope)
{
BlobClientConfiguration blobClientConfiguration = BlobClientConfiguration.DeepCopy(ClientConfiguration);
blobClientConfiguration.EncryptionScope = encryptionScope;
return new BlockBlobClient(Uri, blobClientConfiguration);
}
public virtual Response<BlobContentInfo> Upload(Stream content, BlobUploadOptions options, CancellationToken cancellationToken = default(CancellationToken))
{
return GetPartitionedUploader(options?.TransferOptions ?? default(StorageTransferOptions), options?.TransferValidation ?? ClientConfiguration.TransferValidation.get_Upload(), null, "BlockBlobClient.Upload").UploadInternal(content, null, options, options?.ProgressHandler, false, cancellationToken).EnsureCompleted();
}
[AsyncStateMachine(typeof(<UploadAsync>d__31))]
public virtual Task<Response<BlobContentInfo>> UploadAsync(Stream content, BlobUploadOptions options, CancellationToken cancellationToken = default(CancellationToken))
{
<UploadAsync>d__31 stateMachine = default(<UploadAsync>d__31);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.content = content;
stateMachine.options = options;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Response<BlobContentInfo> Upload(Stream content, BlobHttpHeaders httpHeaders = null, IDictionary<string, string> metadata = null, BlobRequestConditions conditions = null, AccessTier? accessTier = default(AccessTier?), IProgress<long> progressHandler = null, CancellationToken cancellationToken = default(CancellationToken))
{
return Upload(content, new BlobUploadOptions {
HttpHeaders = httpHeaders,
Metadata = metadata,
Conditions = conditions,
AccessTier = accessTier,
ProgressHandler = progressHandler
}, cancellationToken);
}
[AsyncStateMachine(typeof(<UploadAsync>d__33))]
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Task<Response<BlobContentInfo>> UploadAsync(Stream content, BlobHttpHeaders httpHeaders = null, IDictionary<string, string> metadata = null, BlobRequestConditions conditions = null, AccessTier? accessTier = default(AccessTier?), IProgress<long> progressHandler = null, CancellationToken cancellationToken = default(CancellationToken))
{
<UploadAsync>d__33 stateMachine = default(<UploadAsync>d__33);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.content = content;
stateMachine.httpHeaders = httpHeaders;
stateMachine.metadata = metadata;
stateMachine.conditions = conditions;
stateMachine.accessTier = accessTier;
stateMachine.progressHandler = progressHandler;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<UploadInternal>d__34))]
internal virtual Task<Response<BlobContentInfo>> UploadInternal(Stream content, BlobHttpHeaders blobHttpHeaders, IDictionary<string, string> metadata, IDictionary<string, string> tags, BlobRequestConditions conditions, AccessTier? accessTier, BlobImmutabilityPolicy immutabilityPolicy, bool? legalHold, IProgress<long> progressHandler, UploadTransferValidationOptions transferValidationOverride, string operationName, bool async, CancellationToken cancellationToken)
{
<UploadInternal>d__34 stateMachine = default(<UploadInternal>d__34);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.content = content;
stateMachine.blobHttpHeaders = blobHttpHeaders;
stateMachine.metadata = metadata;
stateMachine.tags = tags;
stateMachine.conditions = conditions;
stateMachine.accessTier = accessTier;
stateMachine.immutabilityPolicy = immutabilityPolicy;
stateMachine.legalHold = legalHold;
stateMachine.progressHandler = progressHandler;
stateMachine.transferValidationOverride = transferValidationOverride;
stateMachine.operationName = operationName;
stateMachine.async = async;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Response<BlockInfo> StageBlock(string base64BlockId, Stream content, byte[] transactionalContentHash, BlobRequestConditions conditions, IProgress<long> progressHandler, CancellationToken cancellationToken)
{
return StageBlockInternal(base64BlockId, content, transactionalContentHash.ToValidationOptions(), conditions, progressHandler, false, cancellationToken).EnsureCompleted();
}
[AsyncStateMachine(typeof(<StageBlockAsync>d__36))]
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Task<Response<BlockInfo>> StageBlockAsync(string base64BlockId, Stream content, byte[] transactionalContentHash, BlobRequestConditions conditions, IProgress<long> progressHandler, CancellationToken cancellationToken)
{
<StageBlockAsync>d__36 stateMachine = default(<StageBlockAsync>d__36);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlockInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.base64BlockId = base64BlockId;
stateMachine.content = content;
stateMachine.transactionalContentHash = transactionalContentHash;
stateMachine.conditions = conditions;
stateMachine.progressHandler = progressHandler;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
public virtual Response<BlockInfo> StageBlock(string base64BlockId, Stream content, BlockBlobStageBlockOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
return StageBlockInternal(base64BlockId, content, options?.TransferValidation, options?.Conditions, options?.ProgressHandler, false, cancellationToken).EnsureCompleted();
}
[AsyncStateMachine(typeof(<StageBlockAsync>d__38))]
public virtual Task<Response<BlockInfo>> StageBlockAsync(string base64BlockId, Stream content, BlockBlobStageBlockOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
<StageBlockAsync>d__38 stateMachine = default(<StageBlockAsync>d__38);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlockInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.base64BlockId = base64BlockId;
stateMachine.content = content;
stateMachine.options = options;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<StageBlockInternal>d__39))]
internal virtual Task<Response<BlockInfo>> StageBlockInternal(string base64BlockId, Stream content, UploadTransferValidationOptions transferValidationOverride, BlobRequestConditions conditions, IProgress<long> progressHandler, bool async, CancellationToken cancellationToken)
{
<StageBlockInternal>d__39 stateMachine = default(<StageBlockInternal>d__39);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlockInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.base64BlockId = base64BlockId;
stateMachine.content = content;
stateMachine.transferValidationOverride = transferValidationOverride;
stateMachine.conditions = conditions;
stateMachine.progressHandler = progressHandler;
stateMachine.async = async;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
public virtual Response<BlockInfo> StageBlockFromUri(Uri sourceUri, string base64BlockId, StageBlockFromUriOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
return StageBlockFromUriInternal(sourceUri, base64BlockId, options?.SourceRange ?? default(HttpRange), options?.SourceContentHash, options?.SourceConditions, options?.DestinationConditions, options?.SourceAuthentication, options?.SourceShareTokenIntent, false, cancellationToken).EnsureCompleted();
}
[AsyncStateMachine(typeof(<StageBlockFromUriAsync>d__41))]
public virtual Task<Response<BlockInfo>> StageBlockFromUriAsync(Uri sourceUri, string base64BlockId, StageBlockFromUriOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
<StageBlockFromUriAsync>d__41 stateMachine = default(<StageBlockFromUriAsync>d__41);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlockInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.sourceUri = sourceUri;
stateMachine.base64BlockId = base64BlockId;
stateMachine.options = options;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Response<BlockInfo> StageBlockFromUri(Uri sourceUri, string base64BlockId, HttpRange sourceRange, byte[] sourceContentHash, RequestConditions sourceConditions, BlobRequestConditions conditions, CancellationToken cancellationToken)
{
return StageBlockFromUriInternal(sourceUri, base64BlockId, sourceRange, sourceContentHash, sourceConditions, conditions, null, null, false, cancellationToken).EnsureCompleted();
}
[AsyncStateMachine(typeof(<StageBlockFromUriAsync>d__43))]
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Task<Response<BlockInfo>> StageBlockFromUriAsync(Uri sourceUri, string base64BlockId, HttpRange sourceRange, byte[] sourceContentHash, RequestConditions sourceConditions, BlobRequestConditions conditions, CancellationToken cancellationToken)
{
<StageBlockFromUriAsync>d__43 stateMachine = default(<StageBlockFromUriAsync>d__43);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlockInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.sourceUri = sourceUri;
stateMachine.base64BlockId = base64BlockId;
stateMachine.sourceRange = sourceRange;
stateMachine.sourceContentHash = sourceContentHash;
stateMachine.sourceConditions = sourceConditions;
stateMachine.conditions = conditions;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<StageBlockFromUriInternal>d__44))]
private Task<Response<BlockInfo>> (Uri sourceUri, string base64BlockId, HttpRange sourceRange, byte[] sourceContentHash, RequestConditions sourceConditions, BlobRequestConditions conditions, HttpAuthorization sourceAuthentication, FileShareTokenIntent? sourceShareTokenIntent, bool async, CancellationToken cancellationToken)
{
<StageBlockFromUriInternal>d__44 stateMachine = default(<StageBlockFromUriInternal>d__44);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlockInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.sourceUri = sourceUri;
stateMachine.base64BlockId = base64BlockId;
stateMachine.sourceRange = sourceRange;
stateMachine.sourceContentHash = sourceContentHash;
stateMachine.sourceConditions = sourceConditions;
stateMachine.conditions = conditions;
stateMachine.sourceAuthentication = sourceAuthentication;
stateMachine.sourceShareTokenIntent = sourceShareTokenIntent;
stateMachine.async = async;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
public virtual Response<BlobContentInfo> CommitBlockList(IEnumerable<string> base64BlockIds, CommitBlockListOptions options, CancellationToken cancellationToken = default(CancellationToken))
{
return CommitBlockListInternal(base64BlockIds, options?.HttpHeaders, options?.Metadata, options?.Tags, options?.Conditions, options?.AccessTier, options?.ImmutabilityPolicy, options?.LegalHold, false, cancellationToken).EnsureCompleted();
}
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Response<BlobContentInfo> CommitBlockList(IEnumerable<string> base64BlockIds, BlobHttpHeaders httpHeaders = null, IDictionary<string, string> metadata = null, BlobRequestConditions conditions = null, AccessTier? accessTier = default(AccessTier?), CancellationToken cancellationToken = default(CancellationToken))
{
return CommitBlockListInternal(base64BlockIds, httpHeaders, metadata, null, conditions, accessTier, null, null, false, cancellationToken).EnsureCompleted();
}
[AsyncStateMachine(typeof(<CommitBlockListAsync>d__47))]
public virtual Task<Response<BlobContentInfo>> CommitBlockListAsync(IEnumerable<string> base64BlockIds, CommitBlockListOptions options, CancellationToken cancellationToken = default(CancellationToken))
{
<CommitBlockListAsync>d__47 stateMachine = default(<CommitBlockListAsync>d__47);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.base64BlockIds = base64BlockIds;
stateMachine.options = options;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<CommitBlockListAsync>d__48))]
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Task<Response<BlobContentInfo>> CommitBlockListAsync(IEnumerable<string> base64BlockIds, BlobHttpHeaders httpHeaders = null, IDictionary<string, string> metadata = null, BlobRequestConditions conditions = null, AccessTier? accessTier = default(AccessTier?), CancellationToken cancellationToken = default(CancellationToken))
{
<CommitBlockListAsync>d__48 stateMachine = default(<CommitBlockListAsync>d__48);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.base64BlockIds = base64BlockIds;
stateMachine.httpHeaders = httpHeaders;
stateMachine.metadata = metadata;
stateMachine.conditions = conditions;
stateMachine.accessTier = accessTier;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<CommitBlockListInternal>d__49))]
internal virtual Task<Response<BlobContentInfo>> CommitBlockListInternal(IEnumerable<string> base64BlockIds, BlobHttpHeaders blobHttpHeaders, IDictionary<string, string> metadata, IDictionary<string, string> tags, BlobRequestConditions conditions, AccessTier? accessTier, BlobImmutabilityPolicy immutabilityPolicy, bool? legalHold, bool async, CancellationToken cancellationToken)
{
<CommitBlockListInternal>d__49 stateMachine = default(<CommitBlockListInternal>d__49);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.base64BlockIds = base64BlockIds;
stateMachine.blobHttpHeaders = blobHttpHeaders;
stateMachine.metadata = metadata;
stateMachine.tags = tags;
stateMachine.conditions = conditions;
stateMachine.accessTier = accessTier;
stateMachine.immutabilityPolicy = immutabilityPolicy;
stateMachine.legalHold = legalHold;
stateMachine.async = async;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
public virtual Response<BlockList> GetBlockList(BlockListTypes blockListTypes = BlockListTypes.All, string snapshot = null, BlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
{
return GetBlockListInternal(blockListTypes, snapshot, conditions, false, cancellationToken).EnsureCompleted();
}
[AsyncStateMachine(typeof(<GetBlockListAsync>d__51))]
public virtual Task<Response<BlockList>> GetBlockListAsync(BlockListTypes blockListTypes = BlockListTypes.All, string snapshot = null, BlobRequestConditions conditions = null, CancellationToken cancellationToken = default(CancellationToken))
{
<GetBlockListAsync>d__51 stateMachine = default(<GetBlockListAsync>d__51);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlockList>>.Create();
stateMachine.<>4__this = this;
stateMachine.blockListTypes = blockListTypes;
stateMachine.snapshot = snapshot;
stateMachine.conditions = conditions;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<GetBlockListInternal>d__52))]
private Task<Response<BlockList>> GetBlockListInternal(BlockListTypes blockListTypes, string snapshot, BlobRequestConditions conditions, bool async, CancellationToken cancellationToken)
{
<GetBlockListInternal>d__52 stateMachine = default(<GetBlockListInternal>d__52);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlockList>>.Create();
stateMachine.<>4__this = this;
stateMachine.blockListTypes = blockListTypes;
stateMachine.snapshot = snapshot;
stateMachine.conditions = conditions;
stateMachine.async = async;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
public virtual Response<BlobDownloadInfo> Query(string querySqlExpression, BlobQueryOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
return QueryInternal(querySqlExpression, options, false, cancellationToken).EnsureCompleted();
}
[AsyncStateMachine(typeof(<QueryAsync>d__54))]
public virtual Task<Response<BlobDownloadInfo>> QueryAsync(string querySqlExpression, BlobQueryOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
<QueryAsync>d__54 stateMachine = default(<QueryAsync>d__54);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobDownloadInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.querySqlExpression = querySqlExpression;
stateMachine.options = options;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<QueryInternal>d__55))]
private Task<Response<BlobDownloadInfo>> QueryInternal(string querySqlExpression, BlobQueryOptions options, bool async, CancellationToken cancellationToken)
{
<QueryInternal>d__55 stateMachine = default(<QueryInternal>d__55);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobDownloadInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.querySqlExpression = querySqlExpression;
stateMachine.options = options;
stateMachine.async = async;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
public virtual Stream OpenWrite(bool overwrite, BlockBlobOpenWriteOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
return OpenWriteInternal(overwrite, options, false, cancellationToken).EnsureCompleted();
}
[AsyncStateMachine(typeof(<OpenWriteAsync>d__57))]
public virtual Task<Stream> OpenWriteAsync(bool overwrite, BlockBlobOpenWriteOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
<OpenWriteAsync>d__57 stateMachine = default(<OpenWriteAsync>d__57);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Stream>.Create();
stateMachine.<>4__this = this;
stateMachine.overwrite = overwrite;
stateMachine.options = options;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<OpenWriteInternal>d__58))]
internal Task<Stream> OpenWriteInternal(bool overwrite, BlockBlobOpenWriteOptions options, bool async, CancellationToken cancellationToken)
{
<OpenWriteInternal>d__58 stateMachine = default(<OpenWriteInternal>d__58);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Stream>.Create();
stateMachine.<>4__this = this;
stateMachine.overwrite = overwrite;
stateMachine.options = options;
stateMachine.async = async;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
public virtual Response<BlobContentInfo> SyncUploadFromUri(Uri copySource, bool overwrite = false, CancellationToken cancellationToken = default(CancellationToken))
{
return SyncUploadFromUriInternal(copySource, overwrite ? null : new BlobSyncUploadFromUriOptions {
DestinationConditions = new BlobRequestConditions {
IfNoneMatch = new ETag?(new ETag("*"))
}
}, false, cancellationToken).EnsureCompleted();
}
[AsyncStateMachine(typeof(<SyncUploadFromUriAsync>d__60))]
public virtual Task<Response<BlobContentInfo>> SyncUploadFromUriAsync(Uri copySource, bool overwrite = false, CancellationToken cancellationToken = default(CancellationToken))
{
<SyncUploadFromUriAsync>d__60 stateMachine = default(<SyncUploadFromUriAsync>d__60);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.copySource = copySource;
stateMachine.overwrite = overwrite;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
public virtual Response<BlobContentInfo> SyncUploadFromUri(Uri copySource, BlobSyncUploadFromUriOptions options, CancellationToken cancellationToken = default(CancellationToken))
{
return SyncUploadFromUriInternal(copySource, options, false, cancellationToken).EnsureCompleted();
}
[AsyncStateMachine(typeof(<SyncUploadFromUriAsync>d__62))]
public virtual Task<Response<BlobContentInfo>> SyncUploadFromUriAsync(Uri copySource, BlobSyncUploadFromUriOptions options, CancellationToken cancellationToken = default(CancellationToken))
{
<SyncUploadFromUriAsync>d__62 stateMachine = default(<SyncUploadFromUriAsync>d__62);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.copySource = copySource;
stateMachine.options = options;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<SyncUploadFromUriInternal>d__63))]
internal virtual Task<Response<BlobContentInfo>> SyncUploadFromUriInternal(Uri copySource, BlobSyncUploadFromUriOptions options, bool async, CancellationToken cancellationToken)
{
<SyncUploadFromUriInternal>d__63 stateMachine = default(<SyncUploadFromUriInternal>d__63);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
stateMachine.<>4__this = this;
stateMachine.copySource = copySource;
stateMachine.options = options;
stateMachine.async = async;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
internal PartitionedUploader<BlobUploadOptions, BlobContentInfo> GetPartitionedUploader(StorageTransferOptions transferOptions, UploadTransferValidationOptions validationOptions, ArrayPool<byte> arrayPool = null, string operationName = null)
{
return new PartitionedUploader<BlobUploadOptions, BlobContentInfo>(GetPartitionedUploaderBehaviors(this), transferOptions, validationOptions, arrayPool, operationName);
}
internal static PartitionedUploader<BlobUploadOptions, BlobContentInfo>.Behaviors GetPartitionedUploaderBehaviors(BlockBlobClient client)
{
PartitionedUploader<BlobUploadOptions, BlobContentInfo>.Behaviors result = default(PartitionedUploader<BlobUploadOptions, BlobContentInfo>.Behaviors);
<>c__DisplayClass65_0 <>4__this;
result.SingleUploadStreaming = delegate(Stream stream, BlobUploadOptions args, IProgress<long> progressHandler, UploadTransferValidationOptions validationOptions, string operationName, bool async, CancellationToken cancellationToken) {
<>c__DisplayClass65_0.<<GetPartitionedUploaderBehaviors>b__0>d stateMachine5 = default(<>c__DisplayClass65_0.<<GetPartitionedUploaderBehaviors>b__0>d);
stateMachine5.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
stateMachine5.<>4__this = <>4__this;
stateMachine5.stream = stream;
stateMachine5.args = args;
stateMachine5.progressHandler = progressHandler;
stateMachine5.validationOptions = validationOptions;
stateMachine5.operationName = operationName;
stateMachine5.async = async;
stateMachine5.cancellationToken = cancellationToken;
stateMachine5.<>1__state = -1;
stateMachine5.<>t__builder.Start(ref stateMachine5);
return stateMachine5.<>t__builder.Task;
};
result.SingleUploadBinaryData = delegate(BinaryData content, BlobUploadOptions args, IProgress<long> progressHandler, UploadTransferValidationOptions validationOptions, string operationName, bool async, CancellationToken cancellationToken) {
<>c__DisplayClass65_0.<<GetPartitionedUploaderBehaviors>b__1>d stateMachine4 = default(<>c__DisplayClass65_0.<<GetPartitionedUploaderBehaviors>b__1>d);
stateMachine4.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
stateMachine4.<>4__this = <>4__this;
stateMachine4.content = content;
stateMachine4.args = args;
stateMachine4.progressHandler = progressHandler;
stateMachine4.validationOptions = validationOptions;
stateMachine4.operationName = operationName;
stateMachine4.async = async;
stateMachine4.cancellationToken = cancellationToken;
stateMachine4.<>1__state = -1;
stateMachine4.<>t__builder.Start(ref stateMachine4);
return stateMachine4.<>t__builder.Task;
};
result.UploadPartitionStreaming = delegate(Stream stream, long offset, BlobUploadOptions args, IProgress<long> progressHandler, UploadTransferValidationOptions validationOptions, bool async, CancellationToken cancellationToken) {
<>c__DisplayClass65_0.<<GetPartitionedUploaderBehaviors>b__2>d stateMachine3 = default(<>c__DisplayClass65_0.<<GetPartitionedUploaderBehaviors>b__2>d);
stateMachine3.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine3.<>4__this = <>4__this;
stateMachine3.stream = stream;
stateMachine3.offset = offset;
stateMachine3.args = args;
stateMachine3.progressHandler = progressHandler;
stateMachine3.validationOptions = validationOptions;
stateMachine3.async = async;
stateMachine3.cancellationToken = cancellationToken;
stateMachine3.<>1__state = -1;
stateMachine3.<>t__builder.Start(ref stateMachine3);
return stateMachine3.<>t__builder.Task;
};
result.UploadPartitionBinaryData = delegate(BinaryData content, long offset, BlobUploadOptions args, IProgress<long> progressHandler, UploadTransferValidationOptions validationOptions, bool async, CancellationToken cancellationToken) {
<>c__DisplayClass65_0.<<GetPartitionedUploaderBehaviors>b__3>d stateMachine2 = default(<>c__DisplayClass65_0.<<GetPartitionedUploaderBehaviors>b__3>d);
stateMachine2.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine2.<>4__this = <>4__this;
stateMachine2.content = content;
stateMachine2.offset = offset;
stateMachine2.args = args;
stateMachine2.progressHandler = progressHandler;
stateMachine2.validationOptions = validationOptions;
stateMachine2.async = async;
stateMachine2.cancellationToken = cancellationToken;
stateMachine2.<>1__state = -1;
stateMachine2.<>t__builder.Start(ref stateMachine2);
return stateMachine2.<>t__builder.Task;
};
result.CommitPartitionedUpload = delegate(List<(long Offset, long Size)> partitions, BlobUploadOptions args, bool async, CancellationToken cancellationToken) {
<>c__DisplayClass65_0.<<GetPartitionedUploaderBehaviors>b__4>d stateMachine = default(<>c__DisplayClass65_0.<<GetPartitionedUploaderBehaviors>b__4>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Response<BlobContentInfo>>.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.partitions = partitions;
stateMachine.args = args;
stateMachine.async = async;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
};
result.Scope = ((string operationName) => client.ClientConfiguration.ClientDiagnostics.CreateScope(operationName ?? "Azure.Storage.Blobs.BlobClient.Upload", ActivityKind.Internal));
return result;
}
}
}