Summary: Attend to prep work to get virtual machine cmdlets working.
Honorary Scripting Guy, Sean Kearney is here with some scribbly notes to help you out with Azure scripts for your virtual machines.
Note This is the second post in a series. You might also enjoy reading Manage Azure IaaS with Windows PowerShell: Part 1.
Before you can create virtual machines in Azure, you need to do some prep work to get those virtual machine cmdlets working.
The first thing you need is storage; that is, a place to put your little pile of stuff, because everybody needs a place for their stuff.
Just imagine Azure as a big Hyper-V box that you share with a massive group of people. Before you can create a virtual machine, you need to create a little box to hold your stuff. (Can you tell I've been listening to George Carlin comedy again?)
Normally, you can go into the management portal and create storage in this manner: In the left pane, click STORAGE, and then click +NEW.
Click Quick Create and fill in the following fields:
- The URL for your storage account. Keep in mind that this is a DNS name, and it must be unique and all lowercase letters. Try to pick something you'll remember instead of a random name. It will make things a lot easier to script with. In our example, we have chosen the name eothsgstorage.cloudapp.net.
- A location to hold the storage. This will be one of the presently seven locations in the world. In this example, we are using East US.
- The replication type. This storage account is using Locally Redundant.
Click OK to spin up the process and establish a storage container for our services in Azure.
If you'd like to see the storage accounts under your current subscription, you can leverage the Get-AzureStorageAccount cmdlet. In the following image, we see the output of the cmdlet. Note the AccountType property in addition to the StorageAccountName property:
With these two properties, we can give you the cmdlet that would have created this. It's the New-AzureStorageAccount cmdlet in the following format:
New-AzureStorageAccount –StorageAccountName 'eothsgstorage' –Location 'East US' –type 'Standard_LRS'
So creating (or re-creating) a storage account is actually pretty easy. Your only caveat is to make that you choose a unique name for StorageAccountName and that it's actually part of a DNS name in Azure.
Pop by tomorrow and we’ll dive into more Azure goodness!
I invite you to follow The Scripting Guys on Twitter and Facebook. If you have any questions, send an email to The Scripting Guys at firstname.lastname@example.org, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then remember eat your cmdlets every day with a dash of creativity.
Sean Kearney, Windows PowerShell MVP and Honorary Scripting Guy