Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get a file from an azure container
Param
(
[Parameter(Mandatory=$true)]
[string]$ResourceGroupName,
[Parameter(Mandatory=$false)]
[string]$StorageAccountName,
[Parameter(Mandatory=$true)]
[string]$ContainerName,
[Parameter(Mandatory=$true)]
[string]$Path
)
try
{
$ErrorActionPreference = "Stop"
$Error.Clear()
$AzureStorageAccount = Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName
$AzureStorageContext = $AzureStorageAccount.Context
$AzureStorageContainer = Get-AzureStorageContainer -Name $ContainerName -Context $AzureStorageContext
$CloudBlobContainers = $AzureStorageContainer.CloudBlobContainer.ListBlobs()
foreach ($CloudBlobContainer in $CloudBlobContainers)
{
Get-AzureRmStorageBlobContent -CloudBlob $CloudBlobContainer -Destination $Path -Context $AzureStorageContainer.Context
}
}
catch
{
throw $Error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.