Copy blobs from one storage account to another with a logic app or automation account

Richard Duane Wolford Jr 206 Reputation points
2021-09-09T17:25:23.033+00:00

I have two storage accounts, one in east us 2 and one in central us. When a blob is added to a container named "test" in east us 2, it needs to be automatically copied to the "test" container in central us. So far I've not been able to accomplish this by way of a logic app.

What's the best way to do this without the need of using a VM and AzCopy for example?

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,723 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,447 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,867 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,131 questions
{count} votes

1 answer

Sort by: Most helpful
  1. amon 121 Reputation points Microsoft Employee
    2021-09-14T12:48:29.537+00:00

    Hi @richardwolford-7948

    This can be easily achieved with a combination of Azure Function and azcopy.

    The function should be triggered by a blob addition in your storage account, see example here.

    Add azcopy as a third party dependency in you Azure function, see example here.
    Note: It is recommended to use azcopy to perform the sync because this means you don't need to copy the blob locally, you will simply sync between the storage accounts.

    Once a change is detected and the Function is triggered you can copy the file over. Note: You can use the azcopy "sync" option for simplicity for example: .\dependencies\azcopy.exe sync "https://source-storage.blob.core.windows.net/<source-container>?<SAS-Token>" "https://destination-storage.blob.core.windows.net/<destination-container>?<SAS-Token>" --recursive
    Extra note1: use the --recursive flag for any nested blobs.
    Extra note2: You don't have to use SAS-Token here, using it for simplicity reasons.

    Don't forget to add the connection string for the storage account in your App Settings (so that the trigger will work).

    That's it! Let us know how it goes :)

    1 person found this answer helpful.