Thomas Lee
Thomas Lee

Reputation: 1168

Storage Account Issues?

I am attempting to create a storage group and am running into some issues.

Here is the code I am working with:

$StorageAccountName = 'myazurefileshare'
$Share              = 'FileShare'
$Location           = 'North Europe'
$ac = Get-AzureStorageAccount -StorageAccountName $StorageAccountName -ErrorAction SilentlyContinue
"Storage account exists? [$(if ($ac) {$true} else {$false})]"
If (!$ac)  # Does not exist - so create it
   {
     Write-Verbose "Storage Account [$StorageAccountName] in [$Location] does not exist"
     Write-Verbose "Creating Storage Account [$StorageAccountName] in [$Location]"
     New-AzureStorageAccount -StorageAccountName $StorageAccountName `
        -Location $Location -type 'Standard_GRS'
   }

If I run this with verbose on, I get this:

VERBOSE: 19:58:11 - Begin Operation: Get-AzureStorageAccount
VERBOSE: 19:58:12 - Completed Operation: Get-AzureStorageAccount
Storage account exists? [False]
VERBOSE: Storage Account [myazurefileshare] in [North Europe] does not exist
VERBOSE: Creating Storage Account [myazurefileshare] in [North Europe]
VERBOSE: 19:58:12 - Begin Operation: New-AzureStorageAccount
New-AzureStorageAccount : ConflictError: The storage account named 'myazurefileshare' is already taken.
At line:13 char:6
+      New-AzureStorageAccount -StorageAccountName $StorageAccountName  ...
+      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzureStorageAccount], CloudException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.StorageServices.NewAzureStorageAccountCommand

VERBOSE: 19:58:14 - Completed Operation: New-AzureStorageAccount

So - when I do Get-AzureStorageAccount, it tells me that the storage account does not exist. But when I try to create it, it fails as the name exists. Needless to say, Test-AzureName is consistent with the error returned:

C:> Test-AzureName -Storage myazurefileshare
VERBOSE: The storage account named 'myazurefileshare' is already taken.
True

So why does Get-AzureStorageAccount not return the actual storage account that Test-Azurename says exists?

Clues?

(and sorry for earlier formatting issues!)

Upvotes: 3

Views: 2494

Answers (1)

Mahesh Jasti
Mahesh Jasti

Reputation: 572

storage account names are unique across the subscriptions. When you try to list the account with given name, it is not found under your subscription but is taken by someone else and will not let you create another storage account with the same name.

Upvotes: 7

Related Questions