Azure PowerShell: Copy All Files in Blob Storage to Local Directory

Here’s a Azure PowerShell script that downloads all blobs in a storage container to your local disk:

$storageAccountName = "mysuperstorage"
$containerName = 'my-blobs'
$destinationFolder = 'C:\temp\my-blobs'
New-Item -ItemType Directory -Force -Path $destinationFolder
$storageAccountContext = (Get-AzureRmStorageAccount | Where-Object{$_.StorageAccountName -eq $storageAccountName}).Context
$blobs = Get-AzureStorageBlob -Container $containerName -Context $storageAccountContext
foreach ($blob in $blobs)
  Get-AzureStorageBlobContent -Container $containerName -Blob $blob.Name -Destination $destinationFolder -Context $storageAccountContext

Hope this helps!

This entry was posted in Azure, PowerShell. Bookmark the permalink.

Leave a Reply

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