AzCopy is a command-line utility provided by Microsoft that allows you to upload, download, and copy data to and from Azure Blob, File, and Table storage. Here in this post, we will wolk throug the various ways of image download using AzCopy from Azure Blob Storage.
Image Download using AzCopy from Azure Storage
Getting Started
Azure Blob Storage is a powerful service for storing massive amounts of unstructured data such as images, videos, and documents. When working with Microsoft Azure, you may need to transfer data between your local machine and Azure Storage, especially for tasks involving large files like images or datasets. One of the fastest and most efficient tools to interact with Blob Storage from the command line is AzCopy
, a cross-platform command-line utility designed for high-performance data transfers.
AzCopy is a command-line utility by Microsoft for copying data to and from Microsoft Azure Blob, File, and Table storage. It's especially useful for automatic image download, upload and file transfer. It supports various operations such as uploading, downloading, and copying data within storage accounts.
Prerequisites
AzCopy is a fast, efficient way for image downloading or any other files from Azure Storage. Before we dive into the process, make sure you have the following:- Azure Storage Account with images uploaded in a Blob container.
- AzCopy installed on your machine.
- Access credentials, such as a Shared Access Signature (SAS) or Azure AD credentials.
AzCopy Download and Install
AzCopy is optimized for high-performance data transfer and supports cross-platform usage. My previous post provides a comprehensive guide to downloading and installing AzCopy. To learn how to download and install AzCopy, please refer to my previous post.
Authenticate AzCopy
To download images from Azure blog storage, authentication is required. There are two ways to authenticate AzCopy. The simplest for most users is Azure AD authentication and alternatively, you can use a Shared Access Signature (SAS) token appended to your storage URL if you prefer a script-based, non-interactive approach.
Image Download From Azure Blob Storage
As mentioned above, images can be downloaded using either the Interactive Login or the SAS token approach. Below are the details for downloading images using these two methods.
Basic AzCopy Command: azcopy copy "https://<storage-account>.blob.core.windows.net/<container>/<image-file-name>" "<destination-path>" --recursive=false
Replace:
<storage-account>
– your Azure Storage account name<container>
– name of the container<image-file-name>
– the actual file name (e.g.,photo.jpg
)<destination-path>
– local folder where the image will be saved (e.g.,C:\Images\
or./images/
)
Image Download With Interactive Login
Open the Command Prompt and execute the AzCopy command below. This will open a browser window prompting you to visit https://microsoft.com/devicelogin
and enter a code to authenticate with Azure. Once authenticated, AzCopy will receive a token tied to your Azure AD user account, allowing you to execute the image download commands using AzCopy.
azcopy login
Then use below AzCopy command to download images from Azure Storage
Single Image Download
Syntax azcopy copy "https://<storage_account>.blob.core.windows.net/<container>/<blob_name>" "<local_path>" --recursive=false
Example
azcopy copy "https://mystorageaccount.blob.core.windows.net/images/photo1.jpg" "./downloads/photo1.jpg"
Multiple Image Download
This following examples shows how to download multple images from container and virtual drive
From Container azcopy copy "https://<storage-account>.blob.core.windows.net/<container-name>" "<local-folder>" --recursive=true --include-pattern="*.jpg"
From Virtual Directory
azcopy copy "https://<storage-account>.blob.core.windows.net/<container-name>/images/2025/" "<local-folder>" --recursive=true
Using Image URI List
Create a text file (e.g., filelist.txt) containing blob URLs like:
https://<storage-account>.blob.core.windows.net/<container-name>/img1.jpg
https://<storage-account>.blob.core.windows.net/<container-name>/img2.jpg
Run:
azcopy copy --list-of-urls filelist.txt "<local-folder>"
Note:- In the examples above, we downloaded .jpg images as examples. You can change the extension as needed.
Image Download With SAS Token
Downloading images using a SAS token is straightforward; the AzCopy command can be executed directly with SAS token without logging into Azure Storage. Here are the various examples of image download using azcopy
Basic AzCopy Command: https://<storage-account>.blob.core.windows.net/<container>/<blob-name>?<sas-token>
<SAS_TOKEN>
with everything after the ? in your full SAS URL (excluding the ? if you've already included it).
Single Image Download
Syntax azcopy copy "https://<storage-account>.blob.core.windows.net/<container>/<blob-name>?<sas-token>" "<local-path>" --overwrite=true
Example
azcopy copy "https://mystorage.blob.core.windows.net/images/photo.jpg?<sas-token>" "photo.jpg" --overwrite=true
Multiple Image Download
From Virtual DirectoryThis example will download all avaialble PNG images from subfolder of a container.
azcopy copy "https://yourstorage.blob.core.windows.net/images/*.png?<SAS_TOKEN>" "./images/" --recursive=true
From Container
azcopy copy "https://yourstorageaccount.blob.core.windows.net/yourcontainer/*.jpg?<SAS_TOKEN>" "C:\Users\YourUser\Downloads\" --recursive=true
Summary
AzCopy is a robust and efficient tool for downloading images and other files from Azure Blob Storage. Whether you're managing backups, transferring images for machine learning, or automating pipelines, AzCopy can dramatically simplify your workflow.
Thanks