Previously on Overcast: Azure Resource Manager–First Steps
For my next trick, I will try to deploy two VMs, on the same VNET and add external access endpoints. For that, we will require two new items for our collection: loops and external endpoints.
Let’s start with the loops.
Loops are implemented by the copy directive:
For the number of instances, as you may have noticed, I have created a variable to make things easier.
The interesting part is that the index of the copy is available for you to use, for example, in the name of the objects:
Same for the VMs:
Also note that you need to think in loop, so, each iteration will create a dependency on the specific NIC:
And each VM needs a different VHD:
OK, so let’s give it a spin:
Looks OK:
And it seems fine!
and here:
Now, the next step is to add an external IP to the VM. The IP is actually added to each NIC.
When you use the wizard, it is not smart enough to know you are using copy and creating multiple interfaces, but it is a good start. Again, you have to think in loops and variables, so you’ll need to change a few things.
First, the name:
I’ve created a publicIPName variable and added the copyindex, so the name will be like <publicIPName>0, <publicIPName>1,etc.
I have also created a DNS prefix instead of a name, since I will add a copyindex to it:
remember the rules: the dns name must be unique and lowercase.
The last part is to assign the IP to a NIC. First the dependency:
then the actual IP:
After the deployment finishes, here’s what you get:
And since I have an external IP, I can even RDP to the VM:
Summary
– We have learned how to copy instances of an object to create many
– We have learned how to add public IPs to the VMs
You can find the final Deployment file here.
Hope this helps!