Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

PowerShell – Download Azure Blob Container Content

Posted on September 6, 2017 By David Kittell

You get all of your data into Azure or your application uploads/creates directly into Azure storage and then someone asks you to download the files….

This script below will help you download your files.

$StartTime = $(get-date)
$datetime = $(get-date -f yyyy-MM-dd_hh.mm.ss)

$connection_string = ''
$AzureBlobContainerName = ''

$destination_path = "t:\"
If(!(test-path $destination_path))
{
    New-Item -ItemType Directory -Force -Path $destination_path
}
$storage_account = New-AzureStorageContext -ConnectionString $connection_string

# Download from all containers
#$containers = Get-AzureStorageContainer -Context $storage_account

# Download from specific container
$containers = Get-AzureStorageContainer -Context $storage_account | Where-Object {$_.Name -eq "$AzureBlobContainerName"}

$containers
Write-Host 'Starting Storage Dump...'
foreach ($container in $containers)
{
    Write-Host -NoNewline 'Processing: ' . $container.Name . '...'
    $container_path = $destination_path + '\' + $container.Name
    $blobs = Get-AzureStorageBlob -Container $container.Name -Context $storage_account
    : hu b.nbn   Write-Host -NoNewline ' Downloading files...'    
    foreach ($blob in $blobs)
    {        
        $fileNameCheck = $container_path + '\' + $blob.Name       
        if(!(Test-Path $fileNameCheck ))
        {
            Get-AzureStorageBlobContent `
            -Container $container.Name -Blob $blob.Name -Destination $container_path `
            -Context $storage_account
        }            
    }  
    Write-Host ' Done.'
}
Write-Host 'Download complete.'
$elapsedTime = $(get-date) - $StartTime
$totalTime = "{0:HH:mm:ss}" -f ([datetime]$elapsedTime.Ticks)
Write-Output " -OK $totalTime" | Out-String
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Azure Code PowerShell

Post navigation

Previous post
Next post

Related Posts

Ektron – Widget Form

Posted on March 5, 2014October 26, 2015

In the recent upgrade from Ektron 8.0.2 to 8.7 I’ve been rebuilding forms to user controls that can be used as widgets. Below is basic elements to make the form work for your Ektron 8.7 (possibly higher). Please note the TextBox SubmissionEmail, this allows you to change the email address…

Read More

Red Hat / CentOS / Fedora – Create Jailed SFTP User

Posted on December 26, 2017

If you are working on a project and need SFTP capabilities but don’t want users to see each other’s files create a SFTP Jailed server. Assumptions for the code below is that you are running Red Hat, CentOS, or Fedora and already have the OS running. NOTE: In this first…

Read More

Red Hat 8 – Install NGINX Load Balance DNS

Posted on May 17, 2019

Similar to Ubuntu / Raspberry Pi – Install NGINX Load Balance DNS Some prerequisite posts to look at: Should Run Red Hat – Check Subscription / Register Server SELinux Configuration Change UNIX – Set SSH Banner Should Read/Understand UNIX – Bash Identify Distribution (What OS Am I On) UNIX –…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes