Get-StorageBlobContent
Azure: Downloads a storage blob
param(
[Parameter(Mandatory = $true)]
[string]$Container,
[Parameter(Mandatory = $true)]
[string]$Blob,
[Parameter(Mandatory = $true)]
[string]$Destination,
[Parameter(Mandatory = $true)]
[string]$StorageAccountName
)
try {
Import-Module Az.Storage -ErrorAction Stop
$ctx = (Get-AzStorageAccount -ResourceGroupName "*" -Name $StorageAccountName -ErrorAction Stop).Context
Get-AzStorageBlobContent -Container $Container -Blob $Blob -Destination $Destination -Context $ctx -Force -ErrorAction Stop | Out-Null
Write-Output "Successfully downloaded blob '$Blob' to '$Destination'."
} catch {
Write-Error $_
exit 1
}The name of the storage container.
The name of the blob.
The local path where the blob will be saved.
The name of the storage account for context.