【问题标题】:Set-AzureRmCurrentStorageAccount throws error resourcegroup not foundSet-AzureRmCurrentStorageAccount 抛出错误资源组未找到
【发布时间】:2016-12-02 06:41:14
【问题描述】:

创建 SAS 令牌是目标,并且需要作为先决条件,将所需存储设置为当前存储:

运行以下命令

Set-AzureRmCurrentStorageAccount -ResourceGroupName $StorResourceGroupName -Name $StorageAccountName 

抛出错误:

Set-AzureRmCurrentStorageAccount:找不到资源组“Default-Storage-EastUS”下的资源“Microsoft.Storage/storageAccounts/yoursites”。 在行:1 字符:1 + 设置 AzureRmCurrentStorageAccount -ResourceGroupName $StorResourceGroupName -Name ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Set-AzureRmCurrentStorageAccount], CloudException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Management.Storage.SetAzureRmCurrentStorageAccount

这是抛出错误 New-AzureStorageBlobSASToken -Container $StorageContainer -Blob $blobname -Permission r -ExpiryTime (Get-Date).AddHours(2.0) -FullUri

如何绕过这个问题?

【问题讨论】:

    标签: azure azure-storage azure-powershell


    【解决方案1】:

    我可以想到导致此错误的 2 个原因:

    1. 存储帐户不属于此资源组(如错误所示)。
    2. 存储帐户是Classic 存储帐户(我猜是资源组的名称)。

    请看看其中一个是否确实如此。

    【讨论】:

    • 是的,但我切换到以下上下文方法的原因是,它没有显示在 manage.windowsazure.com 门户上(可能是因为它不是 v1 并且出现了 v2)但显示在门户中。 azure.com ,另一个原因是连接密钥在尝试通过 Cloudberry 连接以探索此帐户时抛出 base-64 未知字符。这些存储类型您是否遇到过类似情况。
    • 另外,下面的方法不提出传递资源组 ID 的挑战,在我看来,上下文对象可以帮助我。
    • 与使用 StorageContext 相比,使用资源组方法的明显优势是您不必记住帐户密钥,因为它会自动获取。关于您面临的错误,我不确定。这可能是 Cloudberry 本身的问题。您是否尝试过其他一些工具?
    【解决方案2】:

    我能够应用的简单替代方法是创建一个存储上下文并另外传递上下文参数。

    示例:-

    #Set Active Storage to Template Storage Context
    $StorageKey = Get-AzureStorageKey -StorageAccountName $StorageAccountName;
    $StorageContext = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageKey.Primary;
    $now = Get-Date
    
    #Create SAS token with temporary access 
    New-AzureStorageBlobSASToken -Container $servicetemplateStorageContainer -Blob $blobname -Context $StorageContext -Permission r -ExpiryTime (Get-Date).AddHours(2.0) -FullUri
    

    希望这有助于为处于类似情况的人提供直接参考。

    【讨论】:

      猜你喜欢
      • 2020-03-18
      • 1970-01-01
      • 2016-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-22
      • 1970-01-01
      相关资源
      最近更新 更多