Use PowerShell to create a Storage Account in Azure

You’ll need to sign up for an Azure account if you don’t already have one: http://azure.microsoft.com. There’s a free trial if you want to try it out.

One thing I would suggest if you’ve never used Azure is to spend a little time in the GUI (your Azure account’s portal website) learning about it before you start trying to manage it with PowerShell. That’s the same advice I would give to anyone wanting to do something with PowerShell. For example, if you want to create an Active Directory user with PowerShell and you’ve never created one in the GUI. Start with the GUI, learn the process, and then move to PowerShell which will give you a better understanding of what you’re trying to accomplish.

There’s a Microsoft article on “How to install and configure Azure PowerShell” that will walk you through the process of installing the Azure PowerShell module so there’s no reason to duplicate that information here.

azure-storage7a

At this point, you should already have your Azure account connected as shown in that article by using the Add-AzureAccount PowerShell cmdlet.

azure-storage8a

One of the first things that you’ll need to do is to setup a storage account. This is necessary before you can start creating VM’s in Azure with PowerShell, but first you’ll need to decide what tier and instance type of VM that you want to create so that you can create the storage account in an Azure datacenter that supports your desired VM type. The virtual machine tier and instance type information can be found here.

Based on that information, I want to create a basic tier instance type A1. I also want to use one of Azure’s datacenters that exists in the United States so based on that information, I’ll use PowerShell to determine which Azure locations support my desired configuration:

azure-storage1a

There are certain restrictions on what characters the storage account name can contain. See this article on “Azure Storage Naming Rules” for details. You’ll receive an error if you try adding something like a dash to it as shown in the following example:

azure-storage2a

New-AzureStorageAccount : Specified argument was out of the range of valid values.
Parameter name: parameters.Name
At line:1 char:1
+ New-AzureStorageAccount -StorageAccountName ‘mikefrobbins-storage’ -L …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureStorageAccount], ArgumentOutOfRangeException
+ FullyQualifiedErrorId : System.ArgumentOutOfRangeException,Microsoft.WindowsAzure.Commands.ServiceManagement.Sto
rageServices.NewAzureStorageAccountCommand

Removing the dash from the name allows the storage account to be created successfully:

azure-storage3a

Now to view the details of this new storage account that’s been created:

azure-storage4a

The description is where you can set a name that is more specific:

azure-storage5a

Now to double check to make sure the new description has been applied:

azure-storage6a

That’s all the time I have for this blog article. Next week, I’ll be building upon this blog article for the next step in this series on managing Azure with PowerShell.

µ

Leave a Reply

%d bloggers like this: