naspinski
naspinski

Reputation: 34689

Azure Storage: use AzCopy.exe to copy a folder from blob storage to another storage account

Using AzCopy.exe, I am able to copy over an entire container successfully. However, I cannot figure out how to copy over a blob where the name includes a folder structure. I have tried the following:

.\AzCopy.exe /Source:https://sourceaccount.blob.core.windows.net/container /Dest:https://destaccount.blob.core.windows.net/container /SourceKey:sourceKey== /DestKey:destKey== /S /Pattern:CorruptZips/2013/6

While also changing the /Pattern: to things like:

And everything just says that there are zero records copied. Can this be done or is it just for container/file copying? Thank you.

Upvotes: 2

Views: 8224

Answers (3)

Nick Schroeder
Nick Schroeder

Reputation: 1462

Took me a few tries to get this. Here is the key:

If the specified source is a blob container or virtual directory, then wildcards are not applied.

In other words, you can't wildcard copy files nested in a folder structure in a container. You have two options:

  • Use /S WITHOUT a pattern to recursive copy everything
  • Use /S and specify the full file path in your pattern without a wildcard

Example:

C:\Users\myuser>azcopy /Source:https://source.blob.core.windows.net/system /Dest:https://dest.blob.core.windows.net/system /SourceKey:abc /DestKey:xyz /S /V /Pattern:"Microsoft.Compute/Images/vmimage/myimage.vhd"

EDIT: Oops, my answer was worded incorrectly!

Upvotes: 0

Peter Pan
Peter Pan

Reputation: 24138

@naspinski, there is the other tool named Azure Data Factory which can help copying a folder from a blob storage account to another one. Please refer to the article Move data to and from Azure Blob using Azure Data Factory to know it and follow the steps below to do.

  1. Create a Data Factory on Azure portal.
  2. Click the Copy Data button as below to move to the powercopytool interface, and follow the tips to copy the folder step by step.

enter image description here

enter image description here

Upvotes: 3

Zhaoxing Lu
Zhaoxing Lu

Reputation: 6467

Please specify the command without /S:

AzCopy /Source:https://myaccount.blob.core.windows.net/mycontainer1 /Dest:https://myaccount.blob.core.windows.net/mycontainer2 /SourceKey:key /DestKey:key /Pattern:abc.txt

You can find the information from "Copy single blob within Storage account" in http://aka.ms/azcopy .

Upvotes: -1

Related Questions