Skip to content

Instantly share code, notes, and snippets.

@Gimly
Created November 13, 2015 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gimly/3d1a10e1f0d004e8b68a to your computer and use it in GitHub Desktop.
Save Gimly/3d1a10e1f0d004e8b68a to your computer and use it in GitHub Desktop.
Copy files from an Azure Blob storage container to a local folder
[CmdletBinding()]
param(
[Parameter(Mandatory=$True)]
[string]$ReleaseFolder,
[Parameter(Mandatory=$True)]
[string]$StorageAccountName,
[Parameter(Mandatory=$True)]
[string]$StorageAccountKey,
[Parameter(Mandatory=$True)]
[string]$Container
)
$storage_account = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
Write-Host "Getting the release directory back from Azure blob storage"
$blobs = Get-AzureStorageBlob -Container $Container -Context $storage_account
New-Item -ItemType Directory -Force -Path $ReleaseFolder
foreach ($blob in $blobs)
{
Get-AzureStorageBlobContent `
-Container $Container -Blob $blob.Name -Force -Destination $ReleaseFolder `
-Context $storage_account
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment