Azure Resource Manager

Azure Resource Manager–Step 3–The Load Balancer

If you checked my previous articles about the two VMs with external IPs, you may have noticed that both VMs get an external IP and that there is no TCP port restriction to them. That won’t likely be the normal situation. Very commonly, you will want something balancing the load between those two identical machines, as well as some control over the ports that can be accessed. In order to accomplish that, we will first create a SINGLE publicIP and then apply to a load balancer entity.

First things first. The Public IP configuration. What I will do is remove the loop and make it a single public IP. This is what I had:

image

Now, after changing:

image

I have also changed the variable names, to represent better what we need to have (names, not prefixes).

image

Next I will remove the reference from the Nics, since the VMs themselves won’t have public IPs:

image

However, you will need to add a dependency on the Load Balancer and assigned NAT rules and backend LB pool:

image

Second, we should add the load balancer itself. It is a tough cookie this one, so let’s take the “Jack the Ripper approach”: Let’s cut it into pieces.

But first, let’s take a look from a high level. Here’s the skeleton of the beast:

image

Important information:

1. “type”: “Microsoft.Network/loadBalancers”, –> sort of obvious.

2. “dependsOn”: [     “[concat(‘Microsoft.Network/publicIPAddresses/’, variables(‘PublicIPName’))]”       ], –> it needs the external IP to work.

3. “frontendIPConfigurations” –> Contains the name of the external LB IP and a reference to the external IP we have created before.

image

4.  “backendAddressPools” -> This configuration will have the name and the backend IP addresses. In this case, the names are sort of hardcoded (allowing only two IPs).

image

5. “inboundNatRules” –> as the name states, this will create NAT rules to allow certain protocols through the load balancer. This used to be done with a cloud service in the old service model.

image

Notice that I’m basically mapping Port 50001 and 50002 to 3389 through the same external IP to the respective internal VM IPs.

6.  “loadBalancingRules” –> here’s where you’ll define which ports (services) will be load-balanced:

image

7. “probes”: And finally, how to detect the availability of the load-balanced services:

image

I have also added an Availability set, just so I can get guaranteed 99.95% availability:

image

It’s location:

image

And assigned the VMs:

image

Once deployed, you’ll hopefully see this:

image

And this:

image

 

Now for a quick testing. Let’s deploy IIS to both VMs, change the default website and test the LB. Notice that because I have a LB rule, I can Connect to the VM:

image

image

Just accept the the next question and there you are:

image

Let’s add IIS to both VMs:

Add-WindowsFeature Web-Server,web-mgmt-console

And add something to identify each one of the VMs:

imageimage

Now, when opening the page from the outside:

image and

image

So! That concludes or tutorial! You can find the template here.

I hope this helps!

Leave a Reply

Your email address will not be published. Required fields are marked *