Copy Data Between Azure Storage Account Fileshares

Requirement: Transfer or Copy Data from an Azure Storage Account Fileshare to Another Storage Account Fileshare or to the Same Source Storage Account of Another Fileshare.

Solution: We can achieve this using the AzCopy tool.

Prerequisites:

  • Azure Portal Resource Access
  • Source and Destination Storage Accounts
  • SAS Token for Source and Destination Storage Accounts
  • AzCopy Tool
Pre-Check list:
  • Your client must have network access to both the source and destination storage accounts.
  • Ensure that both accounts belong to the same Microsoft Entra tenant.
  • Make sure you have authorization credentials for both the source and destination storage accounts. You can use either Microsoft Entitlement (Entra) ID or append a Shared Access Signature (SAS) token to the URLs.

Solution Part to Transfer Data from Source Fileshare to Destination Fileshare in Azure

Download and install AzCopy

Login to your Azure Tenant account using the following command.

azcopy login --tenant-id="<add your tenant id>"

To sign in use the web browser to open the page - https://microsoft.com/devicelogin and Enter the Code xxxxxx to authenticate.

The following is the AzCopy command syntax for copying or transferring data from an Azure Storage Account Fileshare to another Storage Account Fileshare.

Syntax:

azcopy copy 'https://<source-storage-account-name>.file.core.windows.net/<file-share-name><SAS-token>' 'https://<destination-storage-account-name>.file.core.windows.net/<file-share-name><SAS-token>' --recursive

'https://<source-storage-account-name>.file.core.windows.net/<file-share-name><SAS-token>': This part represents the source file share. You need to replace <source-storage-account-name> with the actual name of your source storage account, <file-share-name> with the name of the file share you want to copy from, and <SAS-token> with the shared access signature (SAS) token for authentication.

'https://<destination-storage-account-name>.file.core.windows.net/<file-share-name><SAS-token>': Similarly, this part represents the destination file share. Replace <destination-storage-account-name> with the name of your destination storage account, <file-share-name> with the target file share, and <SAS-token> with the appropriate SAS token.

--recursive: This flag indicates that the copy operation should be recursive, meaning it will copy all files and directories within the specified source file share.