【问题标题】:Enumerating Azure storage account using Powershell使用 Powershell 枚举 Azure 存储帐户
【发布时间】:2020-01-13 13:52:48
【问题描述】:

PowerShell 版本:5.1

我在 PowerShell 中运行此命令以获取容器中的 blob 列表。

$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}

并得到以下错误:

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

【问题讨论】:

  • 我无法在我的系统上复制该错误,但 this question 与类似错误有关

标签: powershell azure-storage azure-blob-storage


【解决方案1】:

根据@Nick Graham 的评论,我确实确保已卸载 AzureRm 模块。详情here.

这是我完美运行的新版本命令。

$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}

【讨论】:

    猜你喜欢
    • 2017-06-20
    • 2021-09-21
    • 2017-06-28
    • 2021-05-12
    • 2019-06-16
    • 2018-02-10
    • 2021-08-21
    • 1970-01-01
    • 2021-11-15
    相关资源
    最近更新 更多