Skip to content

Instantly share code, notes, and snippets.

@pkirch
Created April 7, 2015 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkirch/0f338126ac0e3e9376aa to your computer and use it in GitHub Desktop.
Save pkirch/0f338126ac0e3e9376aa to your computer and use it in GitHub Desktop.
# Get all BLOBs from source container and start copy operation asynchronously for all files based on $fileFilter.
Get-AzureStorageBlob -Context $sourceStorageContext -Container $sourceStorageContainer -Blob $fileFilter |
Start-AzureStorageBlobCopy -DestContext $destinationStorageContext -DestContainer $destinationStorageContainer
# Check copy state in destination container.
$waitTime = 5 # Initial wait time.
do {
# Wait some time before refresh of copy state, except on first iteration.
if ($copyState) {
Write-Host "Refresh in $waitTime seconds."
# After each iteration wait some more time.
Start-Sleep -Seconds ($waitTime++)
}
# Get all BLOBs in destination container and get copy state for all of them.
$copyState = Get-AzureStorageBlob -Context $destinationStorageContext -Container $destinationStorageContainer -Blob $fileFilter |
Get-AzureStorageBlobCopyState
# Print formatted output.
$copyState | Format-Table -Property CopyId, Status, TotalBytes, BytesCopied, @{Name = "Progress"; Expression = {$_.BytesCopied / $_.TotalBytes * 100}; FormatString = "0.00" }, CompletionTime -AutoSize
} while ($copyState.Status -contains "Pending")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment