Share via


CloudBlob.DownloadToFileParallelAsync Method

Definition

Overloads

DownloadToFileParallelAsync(String, FileMode, Int32, Nullable<Int64>, Int64, Nullable<Int64>, AccessCondition, BlobRequestOptions, OperationContext, CancellationToken)

Initiates an asynchronous operation to download the contents of a blob to a file by making parallel requests.

DownloadToFileParallelAsync(String, FileMode, Int32, Nullable<Int64>, CancellationToken)

Initiates an asynchronous operation to download the contents of a blob to a file by making parallel requests.

DownloadToFileParallelAsync(String, FileMode, Int32, Nullable<Int64>)

Initiates an asynchronous operation to download the contents of a blob to a file by making parallel requests.

DownloadToFileParallelAsync(String, FileMode, Int32, Nullable<Int64>, Int64, Nullable<Int64>, AccessCondition, BlobRequestOptions, OperationContext, CancellationToken)

Initiates an asynchronous operation to download the contents of a blob to a file by making parallel requests.

[Microsoft.Azure.Storage.DoesServiceRequest]
public virtual System.Threading.Tasks.Task DownloadToFileParallelAsync (string path, System.IO.FileMode mode, int parallelIOCount, long? rangeSizeInBytes, long offset, long? length, Microsoft.Azure.Storage.AccessCondition accessCondition, Microsoft.Azure.Storage.Blob.BlobRequestOptions options, Microsoft.Azure.Storage.OperationContext operationContext, System.Threading.CancellationToken cancellationToken);
[<Microsoft.Azure.Storage.DoesServiceRequest>]
abstract member DownloadToFileParallelAsync : string * System.IO.FileMode * int * Nullable<int64> * int64 * Nullable<int64> * Microsoft.Azure.Storage.AccessCondition * Microsoft.Azure.Storage.Blob.BlobRequestOptions * Microsoft.Azure.Storage.OperationContext * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.DownloadToFileParallelAsync : string * System.IO.FileMode * int * Nullable<int64> * int64 * Nullable<int64> * Microsoft.Azure.Storage.AccessCondition * Microsoft.Azure.Storage.Blob.BlobRequestOptions * Microsoft.Azure.Storage.OperationContext * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function DownloadToFileParallelAsync (path As String, mode As FileMode, parallelIOCount As Integer, rangeSizeInBytes As Nullable(Of Long), offset As Long, length As Nullable(Of Long), accessCondition As AccessCondition, options As BlobRequestOptions, operationContext As OperationContext, cancellationToken As CancellationToken) As Task

Parameters

path
String

A string containing the path to the target file.

mode
FileMode

A FileMode enumeration value that determines how to open or create the file.

parallelIOCount
Int32

The maximum number of ranges that can be downloaded concurrently

rangeSizeInBytes
Nullable<Int64>

The size of each individual range in bytes that is being dowloaded in parallel. The range size must be a multiple of 4 KB and a minimum of 4 MB. If no value is passed a default value of 16 MB or 4MB if transactional MD5 is enabled.

offset
Int64

The offset of the blob.

length
Nullable<Int64>

The number of bytes to download.

accessCondition
AccessCondition

An AccessCondition object that represents the condition that must be met in order for the request to proceed.

options
BlobRequestOptions

A BlobRequestOptions object that specifies additional options for the request.

operationContext
OperationContext

An OperationContext object that represents the context for the current operation.

cancellationToken
CancellationToken

A CancellationToken to observe while waiting for a task to complete.

Returns

A Task object that represents the asynchronous operation.

Attributes

Remarks

The parallelIOCount and rangeSizeInBytes should be adjusted depending on the CPU, memory, and bandwidth. This API should only be used for larger downloads as a HEAD request is made prior to downloading the data. For smaller blobs, please use DownloadToFileAsync(). To get the best performance, it is recommended to try several values, and measure throughput. One place to start would be to set the parallelIOCount to the number of CPUs. Then adjust the rangeSizeInBytes so that parallelIOCount times rangeSizeInBytes equals the amount of memory you want the process to consume.

Applies to

DownloadToFileParallelAsync(String, FileMode, Int32, Nullable<Int64>, CancellationToken)

Initiates an asynchronous operation to download the contents of a blob to a file by making parallel requests.

[Microsoft.Azure.Storage.DoesServiceRequest]
public virtual System.Threading.Tasks.Task DownloadToFileParallelAsync (string path, System.IO.FileMode mode, int parallelIOCount, long? rangeSizeInBytes, System.Threading.CancellationToken cancellationToken);
[<Microsoft.Azure.Storage.DoesServiceRequest>]
abstract member DownloadToFileParallelAsync : string * System.IO.FileMode * int * Nullable<int64> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.DownloadToFileParallelAsync : string * System.IO.FileMode * int * Nullable<int64> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function DownloadToFileParallelAsync (path As String, mode As FileMode, parallelIOCount As Integer, rangeSizeInBytes As Nullable(Of Long), cancellationToken As CancellationToken) As Task

Parameters

path
String

A string containing the path to the target file.

mode
FileMode

A FileMode enumeration value that determines how to open or create the file.

parallelIOCount
Int32

The maximum number of ranges that can be downloaded concurrently.

rangeSizeInBytes
Nullable<Int64>

The size of each individual range in bytes that is being dowloaded in parallel. The range size must be a multiple of 4 KB and a minimum of 4 MB. If no value is passed a default value of 16 MB is used or 4MB if transactional MD5 is enabled.

cancellationToken
CancellationToken

A CancellationToken to observe while waiting for a task to complete.

Returns

A Task object that represents the asynchronous operation.

Attributes

Examples


// When calling the DownloadToFileParallelAsync API,
// the parallelIOCount variable represents how many ranges can be downloaded concurrently. If the
// parallel I/O count reaches this threshold, no more further requests are made until one range completes.
// The rangeSizeInBytes represents the size of each individual range that is being dowloaded in parallel.
// Passing a cancellation token is advised since for certain network errors, this code will continue to retry indefintitely.
int parallelIOCount = 16;
long rangeSizeInBytes = 16*Constants.MB;
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
await blob.DownloadToFileParallelAsync(outputFileName, FileMode.Create, parallelIOCount, rangeSizeInBytes, cancellationTokenSource.Token);

Remarks

The parallelIOCount and rangeSizeInBytes should be adjusted depending on the CPU, memory, and bandwidth. This API should only be used for larger downloads as a HEAD request is made prior to downloading the data. For smaller blobs, please use DownloadToFileAsync(). To get the best performance, it is recommended to try several values, and measure throughput. One place to start would be to set the parallelIOCount to the number of CPUs. Then adjust the rangeSizeInBytes so that parallelIOCount times rangeSizeInBytes equals the amount of memory you want the process to consume.

Applies to

DownloadToFileParallelAsync(String, FileMode, Int32, Nullable<Int64>)

Initiates an asynchronous operation to download the contents of a blob to a file by making parallel requests.

[Microsoft.Azure.Storage.DoesServiceRequest]
public virtual System.Threading.Tasks.Task DownloadToFileParallelAsync (string path, System.IO.FileMode mode, int parallelIOCount, long? rangeSizeInBytes);
[<Microsoft.Azure.Storage.DoesServiceRequest>]
abstract member DownloadToFileParallelAsync : string * System.IO.FileMode * int * Nullable<int64> -> System.Threading.Tasks.Task
override this.DownloadToFileParallelAsync : string * System.IO.FileMode * int * Nullable<int64> -> System.Threading.Tasks.Task
Public Overridable Function DownloadToFileParallelAsync (path As String, mode As FileMode, parallelIOCount As Integer, rangeSizeInBytes As Nullable(Of Long)) As Task

Parameters

path
String

A string containing the path to the target file.

mode
FileMode

A FileMode enumeration value that determines how to open or create the file.

parallelIOCount
Int32

The maximum number of ranges that can be downloaded concurrently

rangeSizeInBytes
Nullable<Int64>

The size of each individual range in bytes that is being dowloaded in parallel. The range size must be a multiple of 4 KB and a minimum of 4 MB. If no value is passed a default value of 16 MB is used or 4MB if transactional MD5 is enabled.

Returns

A Task object that represents the asynchronous operation.

Attributes

Remarks

The parallelIOCount and rangeSizeInBytes should be adjusted depending on the CPU, memory, and bandwidth. This API should only be used for larger downloads as a HEAD request is made prior to downloading the data. For smaller blobs, please use DownloadToFileAsync(). To get the best performance, it is recommended to try several values, and measure throughput. One place to start would be to set the parallelIOCount to the number of CPUs. Then adjust the rangeSizeInBytes so that parallelIOCount times rangeSizeInBytes equals the amount of memory you want the process to consume.

Applies to