Azure (Classic) Images

“fb83b3509582419d99629ce476bcb5c8__SQL-Server-2014-SP1-12.0.4100.1-Std-ENU-Win2012R2-cy15su05” # Windows 2012 R2, sqlsvr2014 sp1

(8GB / 4-core)

Usage: see here.

November 2016: but these things move on, and the image you choose today may not be there tomorrow. I wrote this to allow me to a) pass in a wildcard when selecting an image, b) get back in the clipboard an arbitrary image name… which realistically means I have to pass in a maximum images of 1. Look at the comments and examples, and you will see what I mean.


Advertisements

Azure CLI: Creating a VM

Although I had vowed not to create a VM again using the Classic deployment model, I was finding it hard to work with Chef in the ARM model. And as it seems that the Azure CLI operates by default against the Classic model… I’m using Azure CLI.


Get the Azure CLI

npm install azure-cli -g

Switch to ASM config mode

azure config mode asm

Download and apply your account settings file

Running this takes you to a browser which prompts you to save the .settings file to your local drive (e.g. c:\temp\ in the example here)

azure account download

Once downloaded, run this:

azure account import “C:\temp\My.publishsettings”

Login

If not authenticated currently, run this, which takes you to another browser:

azure login

List your VMs

azure vm list

List the available VM images from which you can build a VM

azure vm image list

From that list, right now, I am using this VHD, and an example command line of that follows:

a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-20160812-en.us-127GB.vhd

Create a VM

azure vm create ClassicVM01 a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-20160812-en.us-127GB.vhd username password --location "East US"

Note ref the US location that I am in the UK. But variations on “West Europe” do not seem to work in  CLI. Now I failed to specify [-r] in my command line, i.e. enable RDP. So I had to go in to the Azure portal after that and set RDP on port 3389. Also note that the default VM size is “small” if you do not specify a value. Once that is all done, the RDP session includes this:

That is, it is indeed 2012 R2, and it’s Small.

Now you have at least 1 (Classic) VM, running this should return stuff:

azure vm list

Note that it does take a while to get to the ReadyRole status. Before that I got [RoleStateUnknown] followed by [Provisioning]  and [BusyRole]. I think it took about 30 minutes to get to the Ready state.

For fun, I saw there was the nano-server. Let’s see how that plays:

a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2016-Nano-20160801-en.us-8GB.vhd 

azure vm create ClassicVM03 a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2016-Nano-20160801-en.us-8GB.vhd administrator99 HornetsNest99! --location "East US" -r

And actually, that was a bit quicker to deploy. But it turns out it is built to be headless, so no you can’t rdp to it. See here.

Information and errors

The .azure location contains a lot about configuration detail and errors. Take a look:

Create many VMs

Ultimately, I would want to do this through PowerShell (sure, that of course has its own API for this, so you could say a bit perverse). Code is here.

Delete many VMs

And then we want to tidy up. The help extract shows you all you need for the arguments. Code.

And the set created earlier has gone:

And to complete tidy up, update the script (of course you would make this a function after playing) to remove those others:


Hit Subscription Core Limits

Later… and then I tried to get fancy, and create LOTS of VMs. No, I don’t…

BadRequest : The subscription policy limit for resource type ‘cores count’ was exceeded. The limit for resource type ‘cores count’ is 20 per subscription, the current count is 20, and the requested increment is 4.

Azure PowerShell: things have changed

… but of course you don’t get told in anything in-your-face. To wit, this command…

AzureCli19.PNG

… used to return stuff.. and now returns the blank line you see. Turns out this is because Get-AzureVM now refers to the “Classic” variants in the Azure Portal. If you created through the (implicitly recommended) Resource Manager in the Azure Portal, then you now have to use this command:

AzureCli20.PNG

, where the [Rm] part stands for [Resource Manager] . This is a reasonable link.

So that took a while to get there. Next: I have 2 subscriptions. Although I could use this to enumerate my subscriptions, with [123] being my default subscription:

AzureCli21.PNG

, it a LONG time to work out that a) you can only work in one subscription context at a time, and that resources not in the default subscription will not be listed until you do this:

AzureCli22.PNG

With that context set, it will now happily list e.g. the VMs I created on my non-default subscription:

AzureCli20.PNG

And a general MSDN link around those Azure RM cmdlets:

https://msdn.microsoft.com/en-us/library/mt619263.aspx

https://msdn.microsoft.com/en-us/library/mt603718.aspx

And just throwing in some of the keywords/cmdlets I used on the way:

  1. Import-Module -Name PowerShellGet 
  2. Install-Module AzureRM
  3. Install-Module Azure -AllowClobber
  4. Import-Module AzureRM
  5. Get-AzureAccount
  6. Get-AzureVM
  7. Get-AzureRmVM
  8.  Login-AzureRmAccount
  9. Add-AzureRmAccount
  10. Get-AzureRmSubscription

 

By the way, June 22 2016 (that is, just 2 weeks ago) seems a date when a lot changed in PowerShell for Azure. And even the updated docs still talk about “this is early documentation, subject to change, etc…”

Hm, and now I’ve just spotted the “true” CLI ( as opposed to PowerShell):

https://azure.microsoft.com/en-gb/documentation/articles/xplat-cli-install/

Another time. Night.

 

 

Azure: controlling it from a Windows Tablet

Nothing special about this, but it was amusing to stop a VM from my Linx 10″ tablet, just to prove there is nothing to stop that – there shouldn’t be after all, it’s just a Windows 8.1 tablet.

Lin10

In this first shot, having downloaded Azure for PowerShell, you’ll see the error “The server or proxy was not loaded”.

norights01

In the time it took me to Google it, I ran it again, and all was fine this time:

rightsok

And then to stop the service…

stoppedok

These are the rough notes I took while running it for the first time on the Linx:

Download azure.microsoft.com/en-us/downloads

Try Azure command-line interface [Windows install]

takes about 30 minutes say

Add-AzureAccount - this fails first time with proxy error when it asks for authentication, but then succeeds a second time

“Looking for an account” - takes you to the sign on page

Brings up the id type subscription and tenants fine

Prompts you to use get-azuresubsciption

Great - so that works as well (all this so far without arguments)

Now try get-azurevm

Brings back all the VMs with ServiceName, Name, and Status (StoppedDeallocated, ReadyRole)

Now try to stop the ReadyRole one

stop-azurevm -name TheName -ServiceName TheServiceName

prompted for last deployment, resulting in new ip address

Beyond that, I deleted my VMs to staGetAzureVM01