Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell saying storage account doesn't exist

In powershell I verify that it exists by calling the context.

New-AzureStorageContext -StorageAccountName "testdisks401" -StorageAccountKey "...."

Result

StorageAccountName : testdisks401
BlobEndPoint       : https://testdisks401.blob.core.windows.net/
TableEndPoint      : https://testdisks401.table.core.windows.net/
QueueEndPoint      : https://testdisks401.queue.core.windows.net/
FileEndPoint       : https://testdisks401.file.core.windows.net/
Context            : Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext
Name               :
StorageAccount     : BlobEndpoint=https://testdisks401.blob.core.windows.net/;QueueEndpoint=https://testdisks401.queue.core.windows.net/;TableEndpoint=https://testdi
                 sks401.table.core.windows.net/;FileEndpoint=https://testdisks401.file.core.windows.net/;AccountName=testdisks401;AccountKey=[key hidden]
EndPointSuffix     : core.windows.net/

When I try to set it here:

Set-AzureSubscription -SubscriptionName 'XXXX' -CurrentStorageAccount "testdisks401"

I get this

Set-AzureSubscription : ResourceNotFound: The storage account 'testdisks401' was not found.
At line:1 char:1
+ Set-AzureSubscription -SubscriptionName 'XXX
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : CloseError: (:) [Set-AzureSubscription], CloudException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.SetAzureSubscriptionCommand

Been stuck for quite a while. I basically want to write shellscript to create a VM from an existing OS disc. I managed to create a copy of an existing disc using powershell (used context from first command to make it work). But now that I am trying to create the VM configuration using this:

 $vmI1 = New-AzureVMConfig -Name "TestRecover" -InstanceSize Small -AvailabilitySetName 'RDGW' -DiskName 'MY-OS-Disk-Name'

I get this error:

New-AzureVMConfig : Must specify MediaLocation or set a current storage account using Set-AzureSubscription.
At line:1 char:9
+ $vmI1 = New-AzureVMConfig -Name "TestRecover" -InstanceSize Small -Av ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [New-AzureVMConfig], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.NewAzureVMConfigCommand

A solution has already been provided for this which brought me here (stuck on missing storage account error).

like image 705
Moussa Khalil Avatar asked Dec 24 '22 01:12

Moussa Khalil


1 Answers

Set-AzureSubscription Cmdlet expects the storage account specified via -CurrentStorageAccount parameter to be a classic storage account.

Please make sure that you're specifying a classic storage account's name and not a resource manager storage account's name.

like image 108
Gaurav Mantri Avatar answered Jan 04 '23 23:01

Gaurav Mantri