I am trying to use Get-StorageBlobContent to download a blob to local directory. However when I specify the container directory of the blob I get an error. My code looks something like this:
$ctx = New-AzureStorageContext $StorageAccountName -StorageAccountKey $StorageAccountKey
$BlobName = "blob123.vhd"
$LocalTargetDirectory = "D:\vhds"
$ContainerName = transfer/2018/vhds
$Get-AzureStorageBlobContent -Blob $BlobName -Container $ContainerName -Destination $LocalTargetDirectory -Context $ctx
It complains that the container name I specify is not a valid:
Container name 'transfer/2018/vhds' is invalid. Valid names start and end with a lower case letter or a number and has in between a lower case letter, number or dash with no consecutive
My question is then, if the blob I am trying to copy is in a folder in a storage account, how do I correctly give its location?
Any help would be appreciated!
Try something like the following:
$ctx = New-AzureStorageContext $StorageAccountName -StorageAccountKey $StorageAccountKey
$BlobName = "2018/vhds/blob123.vhd"
$LocalTargetDirectory = "D:\vhds"
$ContainerName = "transfer"
$Get-AzureStorageBlobContent -Blob $BlobName -Container $ContainerName -Destination $LocalTargetDirectory -Context $ctx
I am assuming that your blob container name is transfer
and blob123.vhd
is present in 2018/vhds
folder.