Reputation: 11
When running the cmdlet Get-AzureStorageAccount
, I get the following error (See below). I've already connected to my subscription, (get-AzureSubscriptions
returns the subscription id & name, but CurrentStorageAccountName
is blank).
Get-AzureLocation
also fails.
Any pointers???
PS C:\> Get-AzureStorageAccount
VERBOSE: 09:42:35 - Begin Operation: Get-AzureStorageAccount
Get-AzureStorageAccount : An error occurred while sending the request.
At line:1 char:1
+ Get-AzureStorageAccount
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-AzureStorageAccount], HttpRequestException
+ FullyQualifiedErrorId : System.Net.Http.HttpRequestException,Microsoft.WindowsAzure.Commands.ServiceManagement.S
torageServices.GetAzureStorageAccountCommand
Upvotes: 1
Views: 6000
Reputation: 14537
One reason this can occur is if the Azure PowerShell cmdlets are running in Azure Service Management (ASM) mode but the storage account was created in Resource Manager mode. Non-classic resources are generally invisible through ASM, and you must get PowerShell to use the Azure Resource Manager (ARM) mode if you want to see them.
(I can't tell for certain whether this is the problem you're having, but even if it isn't, it might be useful to other people who land here having seen similar errors.)
When you create a new storage account in the Azure Portal, you are given a choice between 'Classic' and 'Resource Manager' mode. There are various subtle implications of this choice, one of which is that if you choose Resource Manager mode, the account will not be visible through the old ASM management API.
And if you're using Get-AzureStorageAccount
you are probably using ASM. Prior to v1.0 of the Azure PowerShell cmdlets (which shipped in November 2015), PowerShell used ASM for everything unless you used Switch-AzureMode
cmdlet to switch into AzureResourceManager mode. Since v1.0, they have actually split the commands so if you want to use the ARM API, you would use Get-AzureRmStorageAccount
.
[Edit 9th Nov 2016: deleted paragraph that incorrectly said you can't log in with a Live ID. Not sure what I was thinking there. You can't use a management cert with ARM, but you certainly can log in with a Live ID.]
There may be an alternative. If you happen to know the storage account key through other means, you can just use New-AzureStorageContext -StorageAccountName <youraccount> -StorageAccountKey <your key>
and then you'll be able to work with the account through other Azure cmdlets.
But if you want to be able to discover accounts, or to find out their credentials with PowerShell cmdlets, then if those accounts are created in Resource Manager mode you'll need to log in with an AAD account and use Get-AzureRmStorageAccount
if you're on v1, or if you're on an older version use Switch-AzureMode AzureResourceManager
before doing anything.
Upvotes: 4
Reputation: 21
Make sure you select your Azure subscription:
Select-AzureSubscription -SubscriptionName "<my subscription name>"
Then you can use Get-AzureStorageAccount:
Get-AzureStorageAccount -StorageAccountName "<your storage account name>"
The Get-AzureStorageAccount command will return a description of your Azure storage account. Here is a sample output:
StorageAccountDescription : Implicitly created storage service
AffinityGroup :
Location : East US
GeoReplicationEnabled : True
GeoPrimaryLocation : East US
GeoSecondaryLocation : West US
Label : <your storage account name>
StorageAccountStatus : Created
StatusOfPrimary : Available
StatusOfSecondary : Available
Endpoints : {https://<your storage account name>.blob.core.windows.net/,
https://<your storage account name>.queue.core.windows.net/,
https://<your storage account name>.table.core.windows.net/}
AccountType : Standard_GRS
StorageAccountName : <your storage account name>
OperationDescription : Get-AzureStorageAccount
OperationId : <operation id>
OperationStatus : Succeeded
Upvotes: 0