2016-07-28 33 views
0

要创建SAS令牌是目的和为前提设定期望的存储作为当前的存储需要:的Set-AzureRmCurrentStorageAccount抛出错误资源组没有发现

运行下面的命令

Set-AzureRmCurrentStorageAccount -ResourceGroupName $StorResourceGroupName -Name $StorageAccountName 

抛出错误:

Set-AzureRmCurrentStorageAccount : The Resource 'Microsoft.Storage/storageAccounts/yoursites' under resource group 'Default-Storage-EastUS' was not found. At line:1 char:1 + Set-AzureRmCurrentStorageAccount -ResourceGroupName $StorResourceGroupName -Name ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Set-AzureRmCurrentStorageAccount], CloudException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Management.Storage.SetAzureRmCurrentStorageAccount

这是为 新AzureStorageBlobSASToken - 集装箱$ StorageContainer -Blob $ blobname -perm抛出错误ission r -ExpiryTime(Get-Date).AddHours(2.0)-FullUri

如何绕过此问题?

回答

2

我能想到的两个原因为什么您会收到此错误:

  1. 存储帐户不属于此资源组(按错误指示)。
  2. 存储帐户是一个Classic存储帐户(我猜这是由资源组的名称)。

请看看他们中的一个是否确实如此。

+0

是的,但为什么我切换到下面的上下文方法是,它没有显示在manage.windowsazure.com门户网站上(可能是因为它不是v1并且显示为v2),但在portal.azure.com中显示,并且另一个原因是该连接密钥在尝试通过Cloudberry连接以探索此帐户时投掷64位未知字符。你有没有遇到类似于这些存储类型的东西? –

+0

此外,下面的方法不要把传递资源组ID的挑战,在我看来,上下文对象帮助我。 –

+1

与使用StorageContext相比,使用资源组方法的一个明显优势是您不必记住账户密钥,因为它会自动提取。关于你面临的错误,我不确定。这可能是Cloudberry本身的一个问题。你有没有尝试过其他工具? –

0

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

例子: -

#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 

希望这有助于有人在类似的情景直参考。

相关问题