0
public void MoveFiles(AzureFileClient srcAzureClient, AzureFileClient destAzureClient, ShareClient srcShareClient, ShareClient destShareClient, string dirName)
{
    if (!destAzureClient.ShareClient.GetDirectoryClient(dirName).Exists())
        destAzureClient.ShareClient.GetDirectoryClient(dirName).Create();

    var fileItems = GetChildNodes(srcShareClient, dirName);

    if (fileItems.Count == 0)
        return;

    foreach (var item in fileItems)
    {
        if (item.ShareFileItem.IsDirectory)
        {
            MoveFiles(srcAzureClient, destAzureClient, srcShareClient, destShareClient, $"{dirName}/{item.ShareFileItem.Name}");
        }
        else
        {
            var srcFileClient = srcShareClient.GetDirectoryClient(Path.GetDirectoryName(item.FullPath)).GetFileClient(Path.GetFileName(item.FullPath));
            var destFileClient = destShareClient.GetDirectoryClient(Path.GetDirectoryName(item.FullPath)).GetFileClient(Path.GetFileName(item.FullPath)); 

            if (srcFileClient.Exists())
            {
                destFileClient.StartCopy(srcFileClient.Uri);
            }
        }
    }
}

This code is throwing an error at

destFileClient.StartCopy(srcFileClient.Uri) 

saying

sourceCopy is not verified, connection strings are given to both source & destination fileShare object

I am able to copy files from the same account storage.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
sarvesh t
  • 23
  • 1
  • 5

1 Answers1

0

When copying files (or blobs) across storage accounts, the source file (or blob) must be publicly accessible. This restriction does not apply when the source and destination are in the same storage account.

Because Azure Files are inherently private (there's no concept of ACL like we have in Blob Storage), you are getting this error as Azure Storage Service is not able to read the source file.

To fix this, you would need to create a SAS URL with at least read permission on the source file and use that SAS URL as copy source.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • thank a lot issue is resolved !! I used ShareSasBuilder for that & got the file Uri through ToSasQueryParameters() function – sarvesh t Sep 02 '22 at 04:06