Azure Resource Manager– Step 2–Copy and Public IPs

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:

image

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:

image

Same for the VMs:

image

Also note that you need to think in loop, so, each iteration will create a dependency on the specific NIC:

image

And each VM needs a different VHD:

image

OK, so let’s give it a spin:

image

Looks OK:

image

And it seems fine!

image

and here:

image

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:

image

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:

image

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:

image

then the actual IP:

image

After the deployment finishes, here’s what you get:

image

And since I have an external IP, I can even RDP to the VM:

image

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!