Azcopy: Copying files to an Azure Fileshare using Azcopy 10
Asked Answered
C

4

7

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.

Cageling answered 24/6, 2020 at 14:24 Comment(7)
I am able to run this command without any problem.Scantling
I'm running this from a local drive on a Windows10 machine using a DOS command line. Are you doing anything different?Cageling
Nope. Same thing. I am using version 10.4.3.Scantling
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=<sig>"Scantling
As far as I can see, that's exactly the same format as I'm using. Thanks for trying it out.Cageling
Can you share what your SAS token look like? Please obfuscate the sig portion of it before sharing.Scantling
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.Cageling
C
6

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.

Cageling answered 25/6, 2020 at 8:36 Comment(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.Swarey
M
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

Mitchellmitchem answered 21/4, 2021 at 10:24 Comment(0)
J
2

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
Jeep answered 11/4, 2022 at 22:56 Comment(1)
Awesome. this was exactly my issue. Didn't have the escape \ before the $web.Durmast
C
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  
Ceremony answered 11/3, 2022 at 21:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.