0

PowerShell Version:5.1

I am running this command in PowerShell to get a list of blobs in a container.

$context = New-AzureStorageContext -StorageAccountName"storageAccountNmae" -StorageAccountKey "Storagekey"

Get-AzureStorageContainer -Context $context

$List = Get-AzureStorageBlob -Context $context -Container "ContainerName" -Blob *

$List | ForEach-Object {Write-Output $_.Name}

And getting following error:

Get-AzureStorageContainer : Method not found: 'Void Microsoft.WindowsAzure.Storage.OperationContext.set_StartTime(System.DateTimeOffset)'.
At line:3 char:1
+ Get-AzureStorageContainer -Context $context
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzStorageContainer], StorageException
    + FullyQualifiedErrorId : StorageException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageContainerCommand

Get-AzureStorageBlob : Method not found: 'Void Microsoft.WindowsAzure.Storage.OperationContext.set_StartTime(System.DateTimeOffset)'.
At line:5 char:9
+ $List = Get-AzureStorageBlob -Context $context -Container "dbbackup"  ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzStorageBlob], StorageException
    + FullyQualifiedErrorId : StorageException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobCommand
SqlWorldWide
  • 329
  • 4
  • 20
  • 1
    I'm not able to replicate the error on my system but [this question](https://stackoverflow.com/questions/54615806/powershell-error-remove-azurestorageblob-method-not-found-void) relates to a similar error – Nick Graham Sep 11 '19 at 17:40

1 Answers1

2

Based on @Nick Graham's comment I did make sure AzureRm module is uninstalled. Details here.

Here is my new version of the command that works perfect.

$StorageAccountName = "StorageAccountName"
$ContainerName = "ContainerName"
$context = New-AzStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey 'StorageKey'
Get-AzStorageContainer -Context $context
$List = Get-AzStorageBlob -Container $ContainerName -Context $context
$List | ForEach-Object {Write-Output $_.Name}
SqlWorldWide
  • 329
  • 4
  • 20
  • hi @SqlWorldWide can you answer to this query? https://stackoverflow.com/questions/76169651/how-to-daily-restore-back-up-from-azure-storage-to-azure-sql-database – Gudwlk May 04 '23 at 11:37