6

I'm trying to copy files to and from an Azure Fileshare using AZCopy v10. I have had this successfully working using v8.1 but I keep getting errors using v10.

From the command line I'm using this to copy a file from the local drive to the fileshare;

c:\Temp\azcopy.exe copy "c:\temp\sample.txt" "https://myfiles.file.core.windows.net/dbfiles/sample.txt?SASKeyText"

This generates the error message;

failed to perform copy command due to error: cannot transfer individual files/folders to the root of a service. Add a container or directory to the destination URL

I have tried adding a directory to the fileshare and adding that to the command string but I get the same error.

If I reverse the copy from the fileshare to the local drive I get the error;

failed to perform copy command due to error: account copies are an inherently recursive operation, and thus --recursive is required

I have followed the guide at https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-files but haven't been able to see what's wrong.

Thanks in advance for any help.

Promise Preston
  • 24,334
  • 12
  • 145
  • 143
jhTuppeny
  • 820
  • 1
  • 11
  • 16
  • I am able to run this command without any problem. – Gaurav Mantri Jun 24 '20 at 14:54
  • I'm running this from a local drive on a Windows10 machine using a DOS command line. Are you doing anything different? – jhTuppeny Jun 24 '20 at 15:49
  • Nope. Same thing. I am using version 10.4.3. – Gaurav Mantri Jun 24 '20 at 16:12
  • This is the command I am using `azcopy.exe copy "D:\temp\test.txt" "https://account.file.core.windows.net/dbfiles/sample.txt?st=2020-06-24T15%3A55%3A51Z&se=2020-06-25T15%3A55%3A51Z&sp=rcwdl&sv=2018-03-28&sr=s&sig="` – Gaurav Mantri Jun 24 '20 at 16:14
  • As far as I can see, that's exactly the same format as I'm using. Thanks for trying it out. – jhTuppeny Jun 24 '20 at 19:24
  • Can you share what your SAS token look like? Please obfuscate the `sig` portion of it before sharing. – Gaurav Mantri Jun 25 '20 at 02:14
  • 1
    I have re-checked the SAS token and there was an error. It's a pity that the error message gave no hint that the token was the fault. Thanks for taking the time to have a look. – jhTuppeny Jun 25 '20 at 08:34

4 Answers4

4

The error here was with the SAS token and not the form of the command.

I suppose this should be marked up amongst examples of unhelpful error messages.

Thanks to everyone who took the time to have a look.

jhTuppeny
  • 820
  • 1
  • 11
  • 16
  • 1
    For other people ending up here, I saw this error when copying files from one Azure file share to another in the same storage account, and had to add the SAS to both source AND target urls. – Erik Oct 16 '20 at 10:45
4

I had this same issue when trying to do a copy from my local machine to Azure Blob storage.

This was the command I was running:

azcopy copy --from-to=LocalBlob "C:\AzureStorageTest\my-app\*" "https://myapptest.blob.core.windows.net/%24web" --recursive

But I got the error below:

failed to perform copy command due to error: cannot transfer individual files/folders to the root of a service. Add a container or directory to the destination URL

Here's how I solved it:

I was missing the ?[SAS] argument at the end of the Blob storage location. So instead of this:

azcopy copy --from-to=LocalBlob "C:\AzureStorageTest\my-app\*" "https://myapptest.blob.core.windows.net/%24web" --recursive

I had this:

azcopy copy --from-to=LocalBlob "C:\AzureStorageTest\my-app\*" "https://myapptest.blob.core.windows.net/%24web?[SAS]" --recursive

Note:

  1. The format is azcopy copy "/path/to/dir" "https://[account].blob.core.windows.net/[container]/[path/to/directory]?[SAS]" --recursive. You only need to modify the "/path/to/dir", [account] and [container]/[path/to/directory]. Every other thing remains the way they are.
  2. Specify the source-destination routing using the --from-to=LocalBlob (if you're copying from local to blob storage) argument to be explicit about the copy operation.
  3. My actual Blob storage location is https://myapptest.blob.core.windows.net/$24web but I used https://myapptest.blob.core.windows.net/%24web, since $ will throw some error when used, so %24 was used.

That's all.

I hope this helps

Promise Preston
  • 24,334
  • 12
  • 145
  • 143
0

Here is a sample azcopy script which worked for me

az storage azcopy blob upload
       -c'https://$AZURE_STORAGE_ACCOUNT_NAME.blob.core.windows.net/\\\$web' \
       --account-name $AZURE_STORAGE_ACCOUNT_NAME \
       -s "build/*" \
       --account-key $AZURE_STORAGE_ACCOUNT_ACCESS_KEY \
       --recursive  
0

If you get this error while trying to copy to $web container:

"failed to perform copy command due to error: cannot transfer individual files/folders to the root of a service. Add a container or directory to the destination URL"

Per a solution listed here, we need to add an escape character (\) before $web. Following command (to copy all files and subfolders to web container) worked for me:

azcopy copy "<local_folder>/*" "https://******.blob.core.windows.net/\$web/?<SAS token>" --recursive

Without the escape character, the following command fails with the above error.

azcopy copy "<local_folder>/*" "https://******.blob.core.windows.net/$web/?<SAS token>" --recursive
Ashankz
  • 51
  • 2