Create Azure Storage Account – New-AzureStorageAccount : StorageAccountAlreadyTaken


I was trying to create an Azure Storage Account using PowerShell cmdlets over the weekend and was welcomed by bunch of errors.

Error Message:

PS C:\> New-AzureStorageAccount -ResourceGroupName “TestAvaGRP” -Name “teststorage” -Type “Standard_LRS” -Location “East
US”
New-AzureStorageAccount : StorageAccountAlreadyTaken: The storage account named teststorage is already taken.
At line:1 char:1
+ New-AzureStorageAccount -ResourceGroupName “TestAvaGRP” -Name “teststorage” -Typ …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureStorageAccount], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Management.Storage.NewAzureStorageAccountCommand

I quickly checked the Syntax of New-AzureStorageAccount from the following MSDN link https://msdn.microsoft.com/en-us/library/azure/dn495115.aspx and it says “The New-AzureStorageAccount cmdlet creates an account that provides access to Azure storage services. A storage account is a globally unique resource within the storage system. The account is the parent namespace for the Blob, Queue, and Table services.”

In simple language, this means, if some one else who is not related to your subscription has created the storage account with same name – the command will fail to create the storage account. Your storage account name should be unique because New-AzureStorageAccount runs in global context and not under your subscription. Hopefully Microsoft will get around this as it might cause naming standards issue when creating accounts (if someone else has created the similar storage account else where with same name).

Error Creating Azure Storage Container


Was working on an Azure Storage is fun and it does require hands on experience to understand Azure storage capabilities. This post is targeted on creating an Azure storage account and container. I was successful in creating Azure storage account and face palm with bunch of errors while creating containers. Will dive into the scenario.

Error:

AzureStorageContainer error

Prerequisites: 

This activity assumes your environment has

a) Azure PowerShell modules installed

b) Azure Subscription

c) Co-Admin / Service Administrator access to the subscription

Troubleshooting

  1. Verify your subscription details using Get-Azuresubscription -Current -ExtendedDetails. Verify “IsDefault” & “IsCurrent” set to True.
  2. Verify CurrentStorageAccountName is set to VALID name.

New-AzureStorageContainer. When you run the following command for creating Azure Storage Container, the command use the value defined under CurrentStorageAccountName. In my scenario, i was trying to create a storage container on a Storage Account which didnt exist.

Confusing:

AzureStorageContainer error2

From the above screenshot, it is evident that PowerShell settings takes precedence over GUI.

Clear Azure Subscription Details from PowerShell


Introduction:

When working with Azure + PowerShell, you would download the subscription details using Get-azurepublishsettingsFile cmdlet and work on the default subscription using PowerShell. There are scenarios where you might need to re-populate subscription details, either because of your subscription changes or try to refresh for the changes.

Initial Connection to Azure using PowerShell:

When you initially download the Azure Subscription details using PowerShell, there are 2 locations the information gets stored

a) The website will prompt for the file to download (eg: The <your subscription>-<date>-<Credentials>.Publishsettings), and to be saved in your persistent storage.

b) The .Json file which will be stored under  “C:\Users\Administrator\AppData\Roaming\Windows Azure Powershell” folder and the file corresponding to subscription will be AzureProfile.Json.

 

Make Changes or Re-load the Azure subscription data:

In order to re-load the file, please delete the following files which are listed under section “Initial Connection to Azure using PowerShell” and re-run the cmdlet Get-AzurepublishsettingsFile cmdlet