Az-104Azure

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

  1. Download from: https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10
  2. Extract to a folder (e.g., C:\AzCopy)
  3. 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

FlagPurpose
--overwrite=ifsourcenewerOverwrites destination only if source file is newer
--recursiveCopies all files and subfolders

SAS Token Permissions Reference

PermissionUse Case
ReadDownload/view blobs
AddAppend to append blobs
CreateWrite new blobs
WriteModify existing blobs
DeleteRemove blobs
ListEnumerate blobs in container
Immutable StorageWrite-once-read-many (compliance)
Permanent DeleteDelete 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

TaskCommand
Copy local fileazcopy copy "[local-path]" "[blob-url]?[sas]"
Copy between containersazcopy copy "[src-url]?[sas]" "[dest-url]?[sas]" --recursive
Sync containersazcopy sync "[src]" "[dest]"
Delete blobsazcopy 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=ifsourcenewer flag behavior
  • Understand difference between account-level and container-level SAS

Leave a Reply

Your email address will not be published. Required fields are marked *