To restart the copying of your remaining files after a cancellation, you can use the Data Movement library, which allows you to resume transfers that were interrupted. Here’s how you can do it:
- Persist Transfer Progress: Ensure that the transfer progress was saved to disk. This allows you to resume the transfer from where it left off.
- Initialize TransferManager: Create a
TransferManagerobject configured to resume the transfer. You will need to specify the appropriateStorageResourceProviderinstances. - Resume Transfer: Call the
ResumeTransferAsyncmethod of theTransferManager, providing the transfer ID of the interrupted transfer.
Here’s a code snippet to illustrate:
// Create a token credential
TokenCredential tokenCredential = new DefaultAzureCredential();
TransferManager transferManager = new(new TransferManagerOptions()
{
ProvidersForResuming = new List<StorageResourceProvider>()
{
new BlobsStorageResourceProvider(tokenCredential)
}
});
// Resume the transfer using the transfer ID
TransferOperation resumedTransfer = await transferManager.ResumeTransferAsync(transferId: "YOUR_TRANSFER_ID");
Make sure to replace "YOUR_TRANSFER_ID" with the actual ID of the transfer you want to resume. If you do not have the transfer ID, you can retrieve it using the GetTransfersAsync method.
This approach will help you continue from where the transfer was interrupted, rather than starting over from scratch.