Azcopy copy Usage For Azure file shares

Jasdeep Singh 0 Reputation points
2025-07-03T01:11:47.9866667+00:00

Hi all,

I am trying to copy my file share from one storage account to another for DR use case by running following commands:

## 1. Generate Account Key for src  
source_storage_key =$(az storage account keys list -g <rg> -n <src-storage> --query "[0].value" -o tsv) 


## 2. Create snapshot with timestamp of Source File share for PITR
SNAPSHOT_TIMESTAMP=$(az storage share snapshot \
  --account-name  <acc_name>\
  --account-key  $source_storage_key \
  --name <file_share> \
  --query snapshot -o tsv) 


## 3. Generate SAS for snapshot
  
SRC_SAS=$(az storage share generate-sas \
  --account-name  <acc_name> \
  --account-key $source_storage_key \
  --name <file_share> \
  --permissions rl \
  --expiry $(date -u -d "1 day" '+%Y-%m-%dT%H:%MZ') \
  --https-only \
  -o tsv)

# 4. Get destination storage account key & generate SAS
dest_key=$(az storage account keys list -g <dest-rg> -n <dest-storage> --query "[0].value" -o tsv)

dest_sas=$(az storage share generate-sas -n <dest-share> --account-name <dest-storage> --account-key "$dest_key" --permissions rwl --expiry $(date -u -d "+1 day" '+%Y-%m-%dT%H:%MZ') -o tsv)


# 5. Construct URLs
source_snapshot_url="https://<src-storage>.file.core.windows.net/<src-share>?snapshot=${SNAPSHOT_TIMESTAMP}&${SRC_SAS}"
dest_url="https://<dest-storage>.file.core.windows.net/<dest-share>?$dest_sas"

# 6. AzCopy copy
azcopy copy "$source_snapshot_url" "$dest_url" --recursive --preserve-smb-info --preserve-smb-permissions


Now, if I run azcopy copy with just --recursive flag, my copy is working fine.

But, when I passed these smb flags --preserve-smb-* I started seeing issues.

Getting following error:

Response Details: <Code>InvalidQueryParameterValue</Code><Message>Value for one of the query parameters specified in the request URI is invalid. </Message><QueryParameterName>snapshot</QueryParameterName><QueryParameterValue>2025-07-03T00:03:42.0000000Z</QueryParameterValue><Reason>This operation is only allowed on the root blob. Snapshot should not be provided.</Reason>

Any help on this is would be great.

Thanks

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jasdeep Singh 0 Reputation points
    2025-07-03T01:44:00.7233333+00:00

    Hi,

    Figured it out
    while creating the snapshot url, I was passing snapshot as query param, instead we have to pass sharesnapshot, and it will work.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.