Azure Resource Manager–First Steps

image

After struggling with Azure Resource Manager for a while and feeling like I didn’t understand the details and nuances of the model, I’ve decided to explorer some of the elements in detail.

The first one I’d like to touch is a Virtual Machine. Very common and very basic to any IaaS deployment.

Let’s see what Visual Studio 2015 will give us.I have created an empty project and will try to add the Resources manually:

image

As one would expect, any VM will need to be stored somewhere and have a network card. So, it makes more send to create both before. But we can follow the wizard for now:

image

image

So far, so good:

image

Now, for the VNET:

image

image

image

Ok, after clicking the final Add, here’s what I get:

image

All this is stored in the DeploymentTemplate.json file.

Visual Studio’s wizard creates and assumes a lot of thins, like the Parameters, for example:

image

On a real automated deployment, some of these won’t be manually entered and seed variable might be the best option.

Speaking of which, the variables get created very quickly by the wizard:

image

And notice the definition:

image

Let’s take a look at some of them, starting by the VNET. It assumes one VNET, with 10.0.0.0/16 prefix and two subnet, which I didn’t actually requested (10.0.0.0/24 and 10.0.1.0/24). May not be a bad idea, but we’ll need to review what we need and we don’t. Also, not the names of the Subnets. If you want it to be easy to ready, you should rename those to Frontend/Backend. Or Internal and DMZ.

image

Not for the OS disk, it will use:

image

Ok, for now. For the VM Size, however, Microsoft recommends a much larger machine, which might not be really necessary:

image

So, here’s what I’ve changed so far:

image

Back to the parameters, note that you can allow valid options for the parameters:

image

If the parameters is not specified in the DeploymentTemplate.param.dev.json file, the user will be prompted either here or in the new Azure Portal, which is initially empty:

image

 

Now for the resources themselves, starting with the VNET. Note the // characters as comments. This is not officially supported outside of visual studio. JSON officially won’t allow comments. But for didactic purposes…anything.

image

The the NIC:

image

Before we look at the VM, let’s see the storage account:

image

And finally, the VM:

image

Ok, so what we have is very simple:

image

So, let’s deploy it:

image

On my first try, VS 2015 crashed completely on me for no reason…Second, same thing. Something must be wrong. What about those comments…no luck. It must be something with 2015 RTM and Windows 10. After switching to VS 2013, I can start the deployment:

image

I will create a new Resource Group:

image

image

Now edit the Parameters:

image

And Deploy!

It started to move:

image

And there is a Resource group in the portal:

image

10 minutes later, nothing had happened. I assume something went wrong, like a parameter with an invalid content or something like that.

Before I start trying to troubleshoot, I’ve decided to check a few pre-requisites that might be outdated, like Azure Powershell. I’ve found out I had a version from may and there is a newer one from August 2015, so, let’s upgrade it.

image

I will start clean now, by using PoSh to deploy it. Before I start I will delete the Resource Group in the portal:

image

image

You should have it open in PoSh ISE:

image

To work from here, you’ll need to authenticate and you do that by using Add-AzureAccount.

After running the script (reminder: enable scripts by setting the Execution policy!), I’ve got a significant error:

image

Storage account names must be all lowercase, 3 to 24 characters. As you can see, I had it wrong in the parameters:

image

However, some components were created:

image

Since the VM depends on the storage account, it couldn’t be created. Let’s do it all from the beginning. Hit F5:

image

Using east us. Type in the admin user password. And let’s see.

image

It seems I have forgotten everything about windows and computer names. It is the cloud! It should just work! Smile

However, it won’t. It is still governed by the regular rules and you have to know what you are doing!!!

Let’s try again, just so we never forget! This time, I will change the VM name:

image

Bingo!

image

Meanwhile, in the portal:

image

Note the extra interface there. This happened because I decided not to wipe the Resource Group before trying again and the name of the interface is created concatenating the VMName, so, the previous one is still there.

You may simply wipe the interface:

image

So, I hope this helps you to give the first steps using Azure Resource Manager! If you are feeling bold, make sure you check this link out. There is a lot of templates ready to be used.