💡 Learn more : AzCopy v10.
We've reviewed the following options with Azure Storage so far:
Today, we are going to look at working with AzCopy to manipulate our Azure Storage container that we've been using throughout this series. Feel free to walk through other post in the series to get up to speed.
What is AzCopy? AzCopy is a command-line utility designed for copying data to/from Microsoft Azure Blob, File, and Table storage, using simple commands designed for optimal performance. You can copy data between a file system and a storage account, or between storage accounts. (courtesy of docs)
For this example, I'm going to use Windows. After I downloaded and installed the utility, I navigated inside my command prompt to the following folder
%ProgramFiles(x86)%\Microsoft SDKs\Azure\AzCopy and ran the
azcopy.exe command to ensure everything was working properly.
So you may be wondering if you need to do the device login as we did with the Azure CLI. The answer is no, we'll be using our Azure Storage Access Key.
Go ahead and open the Azure Portal and navigate to the Azure Storage account that we worked with earlier.
Look under Settings, then Access Keys and copy the key1.
Store the key somewhere that you can retrieve it again.
We can easily download a file from our Azure Storage Blob Container that we've been working with earlier with the following command:
AzCopy /Source:https://mbcrumpsa.blob.core.windows.net/images-backup /Dest:C:\mytest /SourceKey:thekeyyoucopiedearlier /Pattern:"mikepic.png"
We can do the reverse and upload a file from our hard disk to Azure Storage Blob Container with the following command:
AzCopy /Source:C:\mytest /Dest:https://mbcrumpsa.blob.core.windows.net/images-backup /DestKey:thekeyyoucopiedearlier /Pattern:"mikepicnew.png"
Keep in mind: The main difference between these two commands is the use of SourceKey for downloading and DestKey for uploading. The key that is being used is identical (named key1 from the example above).
Finally, you can copy from one Azure Storage account to another one with the following command:
AzCopy /Source:https://mbcrumpsa.blob.core.windows.net/images-backup /Dest:https://mbcrumpsa.blob.core.windows.net/images /SourceKey:thekeyyoucopiedearlier /DestKey:thekeyyoucopiedearlier /Pattern:"mikepicnew.png"
In this case, I am copying a file named
images and then I'll refresh the container.