0

I am trying to get the azure container blob contents using Powershell.

Code

$Ctx = New-AzStorageContext -StorageAccountName abc -StorageAccountKey 'xxxx=='
$latestBuild = Get-AzStorageBlob -Context $Ctx -Container jmeter -blob "Script\Load1"
if($latestBuild -ne $null)
{
    foreach($item in $latestBuild)
    { 
        Get-AzStorageBlobContent -Blob $item.name -Container jmeter -Destination C:\ -Context $Ctx -Force
    }
}
else
{
    write-host "Blob is empty !!!"
}

Error

Get-AzStorageBlob : Can not find blob 'Script\Load1' in container 'jmeter', or the blob type is unsupported.
At line:2 char:16
+ ... testBuild = Get-AzStorageBlob -Context $Ctx -Container jmeter -blob " ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (:) [Get-AzStorageBlob], ResourceNotFoundException
    + FullyQualifiedErrorId : ResourceNotFoundException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobCommand

Blob is empty !!!

There are two files present in the Load1 folder :

enter image description here

1 Answer 1

2

that's not how it works, you have to do it differently:

Get-AzStorageBlob -Context $Ctx -Container jmeter -Prefix "Script/Load1"

or just:

Get-AzStorageBlob -Context $Ctx -Container jmeter -Blob "Script/Load1*"

https://learn.microsoft.com/en-us/powershell/module/az.storage/get-azstorageblob?view=azps-3.6.1

Sign up to request clarification or add additional context in comments.

2 Comments

Now it goes to else part and it is not able to find files. Blob is empty !!!
The issue is I am using a backslash instead of forward. -blob Script/Load1* Please correct your answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.