AzCopy
Intro
My notes for using AzCopy to move data to a storage account
Documentation
Tips and Tidbits
AzCopy is a command-line utility that you can use to copy blobs or files to or from a storage account.
You can provide authorization credentials by using Azure Active Directory (AD), or by using a Shared Access Signature (SAS) token.
Copy blobs between Azure storage accounts by using AzCopy
You can copy blobs, directories, and containers between storage accounts by using the AzCopy v10 command-line utility.
Append a SAS token to each source URL.
If you provide authorization credentials by using Azure Active Directory (Azure AD), you can omit the SAS token only from the destination URL.
Resume A Job
azcopy jobs resume <job-id> --source-sas="<sas-token>" --destination-sas="<sas-token>"
When you resume a job, AzCopy looks at the job plan file.
The plan file lists all the files that were identified for processing when the job was first created.
When you resume a job, AzCopy will attempt to transfer all of the files that are listed in the plan file which weren't already transferred.
Download AzCopy Via PowerShell
$url = 'https://aka.ms/downloadazcopy-v10-windows'
$zipFile = '.\azcopy.zip'
Invoke-WebRequest -Uri $Url -OutFile $zipFile
Expand-Archive -Path $zipFile -DestinationPath '.\'
Set-Location -Path 'azcopy*'
AzCopy Login
.\azcopy.exe login
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code A2FXA3SWC to authenticate.
INFO: Logging in under the "Common" tenant. This will log the account in under its home tenant.
INFO: If you plan to use AzCopy with a B2B account (where the account's home tenant is separate from the tenant of the target storage account), please sign in under the target tenant with --tenant-id
Authenticate as an Azure AD user with Blob permissions (
az30306auser1@rogerrcruzyahoo.onmicrosoft.com
)
Upload File
New-Item -Path './az30306bblob.html'
Set-Content './az30306bblob.html' '<h3>Hello from az30306bblob via Azure AD</h3>'
.\azcopy cp './az30306bblob.html' 'https://rogercruzaz303.blob.core.windows.net/container1/az30306bblob.html'
INFO: Scanning...
INFO: Authenticating to destination using Azure AD
INFO: Any empty folders will not be processed, because source and/or destination doesn't have full folder support
Job 1b01d9eb-2a63-1244-46ef-4270e450e0df has started
Log file is located at: C:\Users\Roger\.azcopy\1b01d9eb-2a63-1244-46ef-4270e450e0df.log
0.0 %, 0 Done, 0 Failed, 1 Pending, 0 Skipped, 1 Total,
Job 1b01d9eb-2a63-1244-46ef-4270e450e0df summary
Elapsed Time (Minutes): 0.0334
Number of File Transfers: 1
Number of Folder Property Transfers: 0
Total Number of Transfers: 1
Number of Transfers Completed: 1
Number of Transfers Failed: 0
Number of Transfers Skipped: 0
TotalBytesTransferred: 47
Final Job Status: Completed
Note that only AzCopy is authorized. You can’t access the URI
Invoke-WebRequest -Uri 'https://rogercruzaz303.blob.core.windows.net/container1/az30306bblob.html'
Invoke-WebRequest : ResourceNotFoundThe specified resource does not exist.
RequestId:4d6178fe-f01e-000b-2251-19eb5f000000 Time:2021-03-15T04:14:23.9943329Z
At line:1 char:1