Skip to content

Commit 8828d23

Browse files
Merge pull request #229101 from pauljewellmsft/pauljewell-dmlib-update
Update dm lib article to use consistent enum values
2 parents 2867a23 + ccd44bc commit 8828d23

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

articles/storage/common/storage-use-data-movement-library.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ public static async Task TransferUrlToAzureBlob(CloudStorageAccount account)
464464
ConsoleKeyInfo keyinfo;
465465
try
466466
{
467-
task = TransferManager.CopyAsync(uri, blob, true, null, context, cancellationSource.Token);
467+
task = TransferManager.CopyAsync(uri, blob, CopyMethod.ServiceSideAsyncCopy, null, context, cancellationSource.Token);
468468
while(!task.IsCompleted)
469469
{
470470
if(Console.KeyAvailable)
@@ -490,7 +490,7 @@ public static async Task TransferUrlToAzureBlob(CloudStorageAccount account)
490490
checkpoint = context.LastCheckpoint;
491491
context = GetSingleTransferContext(checkpoint);
492492
Console.WriteLine("\nResuming transfer...\n");
493-
await TransferManager.CopyAsync(uri, blob, true, null, context, cancellationSource.Token);
493+
await TransferManager.CopyAsync(uri, blob, CopyMethod.ServiceSideAsyncCopy, null, context, cancellationSource.Token);
494494
}
495495

496496
stopWatch.Stop();
@@ -499,7 +499,13 @@ public static async Task TransferUrlToAzureBlob(CloudStorageAccount account)
499499
}
500500
```
501501

502-
One important use case for this feature is when you need to move data from another cloud service (e.g. AWS) to Azure. As long as you have a URL that gives you access to the resource, you can easily move that resource into Azure Blobs by using the `TransferManager.CopyAsync` method. This method also introduces a new boolean parameter. Setting this parameter to `true` indicates that we want to do an asynchronous server-side copy. Setting this parameter to `false` indicates a synchronous copy - meaning the resource is downloaded to our local machine first, then uploaded to Azure Blob. However, synchronous copy is currently only available for copying from one Azure Storage resource to another.
502+
One important use case for this feature is when you need to move data from another cloud service (e.g. AWS) to Azure. As long as you have a URL that gives you access to the resource, you can easily move that resource into Azure Blobs by using the `TransferManager.CopyAsync` method. This method also introduces a **CopyMethod** parameter. The following table shows the available options for this parameter:
503+
504+
| Member name | Value | Description |
505+
| --- | --- | --- |
506+
| SyncCopy | 0 | Download data from source to memory, and upload the data from memory to destination. Currently only available for copying from one Azure Storage resource to another. |
507+
| ServiceSideAsyncCopy | 1 | Send a start copy request to Azure Storage to let it do the copying; monitor the copy operation progress until the copy is completed. |
508+
| ServiceSideSyncCopy | 2 | Copy content of each chunk with with [Put Block From URL](/rest/api/storageservices/put-block-from-url), [Append Block From URL](/rest/api/storageservices/append-block-from-url), or [Put Page From URL](/rest/api/storageservices/put-page-from-url). |
503509

504510
## Copy a blob
505511

@@ -522,7 +528,7 @@ public static async Task TransferAzureBlobToAzureBlob(CloudStorageAccount accoun
522528
ConsoleKeyInfo keyinfo;
523529
try
524530
{
525-
task = TransferManager.CopyAsync(sourceBlob, destinationBlob, CopyMethod.ServiceSideAsyncCopy, null, context, cancellationSource.Token);
531+
task = TransferManager.CopyAsync(sourceBlob, destinationBlob, CopyMethod.SyncCopy, null, context, cancellationSource.Token);
526532
while(!task.IsCompleted)
527533
{
528534
if(Console.KeyAvailable)
@@ -548,7 +554,7 @@ public static async Task TransferAzureBlobToAzureBlob(CloudStorageAccount accoun
548554
checkpoint = context.LastCheckpoint;
549555
context = GetSingleTransferContext(checkpoint);
550556
Console.WriteLine("\nResuming transfer...\n");
551-
await TransferManager.CopyAsync(sourceBlob, destinationBlob, false, null, context, cancellationSource.Token);
557+
await TransferManager.CopyAsync(sourceBlob, destinationBlob, CopyMethod.SyncCopy, null, context, cancellationSource.Token);
552558
}
553559

554560
stopWatch.Stop();
@@ -557,7 +563,7 @@ public static async Task TransferAzureBlobToAzureBlob(CloudStorageAccount accoun
557563
}
558564
```
559565

560-
In this example, we set the boolean parameter in `TransferManager.CopyAsync` to `false` to indicate that we want to do a synchronous copy. This means that the resource is downloaded to our local machine first, then uploaded to Azure Blob. The synchronous copy option is a great way to ensure that your copy operation has a consistent speed. In contrast, the speed of an asynchronous server-side copy is dependent on the available network bandwidth on the server, which can fluctuate. However, synchronous copy may generate additional egress cost compared to asynchronous copy. The recommended approach is to use synchronous copy in an Azure VM that is in the same region as your source storage account to avoid egress cost.
566+
In this example, we set the boolean parameter in `TransferManager.CopyAsync` to `CopyMethod.SyncCopy` to indicate that we want to do a synchronous copy. This means that the resource is downloaded to our local machine first, then uploaded to Azure Blob. The synchronous copy option is a great way to ensure that your copy operation has a consistent speed. In contrast, the speed of an asynchronous server-side copy is dependent on the available network bandwidth on the server, which can fluctuate. However, synchronous copy may generate additional egress cost compared to asynchronous copy. The recommended approach is to use synchronous copy in an Azure VM that is in the same region as your source storage account to avoid egress cost.
561567

562568
The data movement application is now complete. [The full code sample is available on GitHub](https://github.com/azure-samples/storage-dotnet-data-movement-library-app).
563569

0 commit comments

Comments
 (0)