Download A Few Files from Azure Blob Storage

Azure Blob Storage is a great and cheap place to upload a lot of files.

One of the websites I am currently work on, stores all the PDFs that users can download, in an Azure Blob Storage container.

We needed to pull down a large amount of those PDFs to confirm the content in them.

So I wrote the following PowerShell:

$LocalTargetDirectory = "D:\Temp\FilesDownloaded\"
$StorageAccountName = "YourStorageAccountName"
$StorageAccountKey = "YourStorageAccountKey"
$ContainerName = "YourContainerName"
$Blobs = @("file1","file2")

New-Item -Force -ItemType directory -Path $LocalTargetDirectory
$Context = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey

foreach($Blob in $Blobs)
{
Get-AzureStorageBlobContent -Blob $Blob -Container $ContainerName -Destination $LocalTargetDirectory -Context $Context
}

To get this to work for you, replace:
LocalTargetDirectory with where you want to download the files to.
StorageAccountName with the name of the Azure Storage Account Name.
StorageAccountKey with the name of the Azure Storage Account Key.
ContainerName with the container that you have the files saved in.
Blobs is an array of the files you want to download from the container.

Leave a Reply

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