I am attempting to create a storage group and am running into some issues.
Here is the code I am working with:
# Azure bug?$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-AzureStorageAccountVERBOSE: 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 myazurefileshareVERBOSE: 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?
C