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:
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:
So far, so good:
Now, for the VNET:
Ok, after clicking the final Add, here’s what I get:
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:
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:
And notice the definition:
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.
Not for the OS disk, it will use:
Ok, for now. For the VM Size, however, Microsoft recommends a much larger machine, which might not be really necessary:
So, here’s what I’ve changed so far:
Back to the parameters, note that you can allow valid options for the parameters:
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:
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.
The the NIC:
Before we look at the VM, let’s see the storage account:
And finally, the VM:
Ok, so what we have is very simple:
So, let’s deploy it:
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:
I will create a new Resource Group:
Now edit the Parameters:
It started to move:
And there is a Resource group in the portal:
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.
I will start clean now, by using PoSh to deploy it. Before I start I will delete the Resource Group in the portal:
You should have it open in PoSh ISE:
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:
Storage account names must be all lowercase, 3 to 24 characters. As you can see, I had it wrong in the parameters:
However, some components were created:
Since the VM depends on the storage account, it couldn’t be created. Let’s do it all from the beginning. Hit F5:
Using east us. Type in the admin user password. And let’s see.
It seems I have forgotten everything about windows and computer names. It is the cloud! It should just work!
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:
Meanwhile, in the portal:
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:
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.