Without much intro let me get started straight with this article. Today I’m going to show you how you can create highly available IIS web farm in Windows Azure environment. Let me highlight that in a picture for easy understanding,
Source for this picture can be found here
As you can see in the above picture we get all the HTTP (port 80) traffic routed through the Azure Load balance to the VM’s hosted in the Azure Cloud Service. In case of single or multiple IIS VM’s failure on the target cloud service traffic will be routed to a available VM on the Cloud service.
Before starting this let me clearly state there are several ways you can approach to complete these tasks so what I describe here might be changed in future or might not be the best method for you 🙂
Let’s start now. First go to the Azure portal and create a new Cloud Service. Cloud service can be considered as a container for the hosted VM’s. If you need more information about that please refer this link.
Once you click “Create Cloud Service” it will take few seconds to create the Cloud service container. After that we need to create two VM’s. For this we’ll go ahead and select VM template from the gallery.
Next screen provide a unique name to the VM and username and password,
In the next page is important to select the pre-created Cloud service container and also create new availability set. In availability set option Azure will make sure two VM’s will be placed on two different fault domains. In simple English that means two VM’s will be on two different host computers in two different racks. This is to avoid single point of failure.
In the next page you’ve to select which ports will be open to the outside world to access. In my case I want to host a IIS web site in secure manner so I plan to open port 443 (HTTPS) for that click the “Enter or Select Value” column and select HTTPS
After that complete the steps to create the first VM. In the second VM’s setup you’ll select the pre created Cloud service name and the Availability Set from the drop down menus.
Ok so far you’ll with me? Cool let’s move to the next step. Remember in the first VM creation part for the endpoints we open port 443 (HTTPs) to the outside world? Well we did that only to the first VM but in case if that VM is down second VM will not be able to respond since we have not open the port 443 in that server. Apart from that we didn’t create a load balancer for the two VMs. So in order to complete that task we’ll go to the azure portal —> Virtual machine’s —> click the first VM name. After that click Endpoints section,
Highlight the HTTPS and then select “Edit” on bottom of the screen,
Notice that HTTPS is not having a Load-Balanceded Set yet i the upper right hand corner? Once you’re in the second page tick “Create a Load Balance Set” Option.
In the next page you can give a name to the Load Balance Set. I’ve put a name as “LB1”. Rest settings I don’t think you’ll need to change unless you have a good reason to do so. Click the correct sign to complete the task.
ok when that task is complete it’s time to move to the next virtual machine and configure the endpoints section by adding the port 443 🙂
Once you click add in the next screen you’ve to select the second option and from the drop down menu need to select the Load Balance Set we’ve created previously.
next screen provide a name to the Load Balance set and avoid any other changes and complete the task. This will take few seconds.
Once the above task is completed you’ve successfully completed load balancing two VM’s for IIS traffic. Now if you ask me how to test that then steps are as follows (at least this is how I test that)
1. Log into each VM (RDP) and then install IIS service. To make this step much quicker I used the PS command as follows,
Install-WindowsFeature Web-Server -IncludeManagementTools –IncludeAllSubFeature
2. Go to the wwwroot of each VM and open the default IIS graphic file from mspaint and provide each VM unique name. (Eg: VM1 I’ll modify that picture by entering the name VM1…etc)
3. Go to the IIS console on both VM’s and bind 443 to the default web site.
4. Now find the public VIP or the DNS name and type that on your machine’s browser. You should be able to see a default IIS web page. Observe from which VM name appear on that page. Go to Azure portal and shutdown that VM and refresh your web page. After little while you’ll see second VM’s IIS default web page will load. And that is your main proof to identify IIS load balance work perfectly.