Reputation: 1321
To create a SAS Token was the aim and required as a precondition setting desired storage as current storage:
Running the following command
Set-AzureRmCurrentStorageAccount -ResourceGroupName $StorResourceGroupName -Name $StorageAccountName
throws error:
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
And this was throwing error for New-AzureStorageBlobSASToken -Container $StorageContainer -Blob $blobname -Permission r -ExpiryTime (Get-Date).AddHours(2.0) -FullUri
How to byepass this issue?
Upvotes: 0
Views: 754
Reputation: 1321
The easy alternative I was able to apply was to create a storage context and pass the context parameter additionally.
Example :-
#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
Hope this helps a straight reference for someone in similar scenario.
Upvotes: 0
Reputation: 136196
I could think of 2 reasons why you may be getting this error:
Classic
storage account (I'm guessing this by the name of the Resource group).Please see if one of them is indeed the case.
Upvotes: 2