Azure AzCopy Study Guide: Storage Replication & SAS Tokens | AZ-104
Study Guide: Azure Storage Management and Replication
AzCopy Essentials
What is AzCopy?
- Command-line utility for copying data to/from Azure Storage
- Authentication methods: Azure AD/Entra ID or SAS tokens
- Primary use cases: Backup replication, environment migration (dev→prod), local data processing
Installation
- Download from:
https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10 - Extract to a folder (e.g.,
C:\AzCopy) - Navigate to folder in PowerShell:
cd C:\AzCopy
Command Syntax
textazcopy [command] [source] [destination] [flags]
Copy Operations
1. Local File to Blob Container (Using SAS Token)
Prerequisites:
- Create container in storage account
- Generate SAS token with permissions: Read, Add, Create, Write, Delete, List
- Set start time 5 minutes before current time
PowerShell Script:
powershell# Variables
$SourceFilePath = "C:\AzCopy\MyFile.txt"
$StorageAccountName = "yourstorageaccount"
$ContainerName = "azcopydestination"
$SASToken = "?sv=your-sas-token"
# Execute
./azcopy.exe copy "$SourceFilePath" "https://$StorageAccountName.blob.core.windows.net/$($ContainerName)$SASToken"
2. Container to Container Copy (Same or Different Storage Accounts)
Source SAS Permissions: Read, List
Destination SAS Permissions: Read, Add, Create, Write, Delete, List
PowerShell Script:
powershell# Variables
$StorageAccountName = "yourstorageaccount"
$SrcContainerName = "azcopysource"
$DestContainerName = "azcopydestination"
$SourceSASToken = "sp=r..."
$DestSASToken = "sp=racwdl..."
# Execute
./azcopy.exe copy "https://$StorageAccountName.blob.core.windows.net/$($SrcContainerName)?$SourceSASToken" "https://$StorageAccountName.blob.core.windows.net/$($DestContainerName)?$DestSASToken" --overwrite=ifsourcenewer --recursive
Key Flags Explained
| Flag | Purpose |
|---|---|
--overwrite=ifsourcenewer | Overwrites destination only if source file is newer |
--recursive | Copies all files and subfolders |
SAS Token Permissions Reference
| Permission | Use Case |
|---|---|
| Read | Download/view blobs |
| Add | Append to append blobs |
| Create | Write new blobs |
| Write | Modify existing blobs |
| Delete | Remove blobs |
| List | Enumerate blobs in container |
| Immutable Storage | Write-once-read-many (compliance) |
| Permanent Delete | Delete snapshots/versions before retention expires (high risk) |
Key Concepts to Know for Exam
AzCopy vs. Other Tools
- AzCopy: Best for scripted/automated bulk transfers, command-line workflows
- Azure Storage Explorer: GUI-based, good for ad-hoc operations
- PowerShell Azure module: Good for automation but slower for large transfers
Immutable Storage
- Data cannot be altered or deleted for a predefined retention period
- Use case: Governance, compliance, legal hold
Permanent Delete
- Allows deletion of blob versions/snapshots before retention period ends
- High-risk permission—use with caution
Additional Topics Covered (High Level)
- Azure File Sync: Caches Azure file shares on-premises
- Blob Object Replication: Async replication between storage accounts
- Blob Lifecycle Management: Automated tiering (Hot→Cool→Archive) for cost optimization
- Blob Versioning: Maintains previous versions of blobs
- Storage Account Deletion: Recovery options and soft delete
Quick Command Reference
| Task | Command |
|---|---|
| Copy local file | azcopy copy "[local-path]" "[blob-url]?[sas]" |
| Copy between containers | azcopy copy "[src-url]?[sas]" "[dest-url]?[sas]" --recursive |
| Sync containers | azcopy sync "[src]" "[dest]" |
| Delete blobs | azcopy remove "[blob-url]?[sas]" |
Practice Checklist
- Install AzCopy and add to PATH
- Generate SAS token with correct resource type (Container vs Object)
- Copy single file to blob storage
- Copy entire folder using
--recursive - Copy between two containers
- Test the
--overwrite=ifsourcenewerflag behavior - Understand difference between account-level and container-level SAS
