Start-AzureStorageBlobCopy accept arrays? Or new bulk copy container command
Goal: Trying to copy blob container to separate container in case storage account gets deleted/snapshot in time/off account copy. Env: Azure Automation Account/Powershell Workflow
Limitation: AzCopy appears to allow single request transfer container. AzCopy is not supported in Azure Automation jobs (unless using own hosted worker).
Following command appears to execute one by one:
Get-AzureStorageBlob -Context $contextSource -Container "$SourceBlobContainer" |
Start-AzureStorageBlobCopy -DestContext $contextDestination -DestContainer "$DestBackupContainer"
In a container with thousands upon thousands of blobs, this appears to generate alot of request overhead (making a job run for hours!). Same scenario using AzCopy: 9 minutes.
AzCopy appears to copy container to container. Can this be achieved with Start-AzureStorageBlobCopy or a new AzureRM command?
Workaround: I was able to workaround this by:
- Not outputting
Start-AzureStorageBlobCopyto console, viaMeasure-Command - Appending
-ConcurrentTaskCount 100to following commands:Start-AzureStorageBlobCopyandGet-AzureStorageBlobCopyState#used when checking status
Both were critical - console output would bog down the command, and the concurrenttaskcount really made a huge difference when checking status.
This cut the whole extent of my job in Azure Automation account from seemingly endless hours to 4 minutes. ~10k files, ~50MB-ish test data set.
@iyerusad
Good to know that you have workaround the issue.
For Blob Copy, in PowerShell it's server side async copy, which has no SLA. The default ConcurrentTaskCount is 10 and only allows 10 network connection. When you change it to 100, and if the network on you machine is good enough, it will make the copy request send fast.
For AzCopy, default it will also use AsyncCopy, but you can switch to SyncCopy (download to local memory and upload) by adding /SyncCopy parameter, and this has SLA. besides that, AzCopy by default will use cpu core * 8 connections.
Let me know if you still need any other information from us.
Thanks @blueww , this is good to know. It might be the cpu core (4) * 8 = 24 in AzCopy was enough to better take advantage of the machine's network vs the default 10 in the Start-AzureStorageBlobCopy cmdlet.
I think it would be helpful to have a "CopyBlobContainer" cmdlet. Start-AzureStorageBlobCopy is focused on blobs, where as I think there is a strong case for cmdlet specific for the container as a whole. There really shouldn't be any reason one should have to iterate over blobs to clone a blob container.
@iyerusad Thanks for the suggestion! For Copy the whole container, Azcopy should be a better choice then powershell. For powershell, we providet the basic function for blob operation, and user can unitlize the powershell script to copy whole container, or some blobs with specific pattern in the container, or even copy to different account/container.
Anyway, this is the first feature request we see for container copy. As we also has some other features in hand, we can consider the feature when there are more customers vote for this feature.
There are multiple stackoverflow (1) (2) questions around this scenario. With containers containing many (10k+) small blobs, it doesn't make much sense to iterate through them one by one to initiate asynchronous copy - some kind of bulk mechanism would be helpful.
Would love to use AzCopy but:
- Can't run in hosted Azure Automation agents.
- Is not cross platform (e.g. AzureCLI)
@iyerusad
I will open a work item for Powershell cmdlet of copy a container. And we will evaluate it according to user requests and our bandwidth.
For many (10k+) blobs in a container, user can list the blobs in batches and then copy one by one. You can find how to list blobs in batches in last help Example of cmdlet Get-AzureStorageBlob.
For AzCopy, it has version that support linux: https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-linux
Close the issue due to idle time. Please reopen if there is till question.