How to configure Azure Websites to communicate with Azure WebRole on Internal Load Balancer Endpoint

I recently worked on configuring Azure Websites to communicate with Azure Web Role on Internal Load Balancer(ILB) Endpoint. The requirement was that the Azure WebRole should not have an external endpoint.

There are 3 things to configure:

1. Configure Azure Websites Virtual Network . If you plan to first create Virtual Network, make sure to have a Dynamic routing gateway and to have Point to Site enabled.

2.  Configure  Internal Load Balancer in the Azure WebRole. (Review the section Internal Load Balancing (ILB) in the referenced article). The changes are to Azure Web Role cscfg and csdef files.

3. Configure the Web Role to connect to Virtual Network  

4. Get the IP address of the Internal Load Balancer (ILB) using Powershell: Get-AzureDeployment -ServiceName websitetowebroleilbvnet2 | Get-AzureInternalLoadBalancer

5. The final config(cscfg) file for the Web Role will look like:

 <VirtualNetworkSite name="VNET NAME" />

    <AddressAssignments>

      <InstanceAddress roleName="WebRole1">

        <Subnets>

          <Subnet name="Subnet-1"/>

        </Subnets>

      </InstanceAddress>

    </AddressAssignments>   

    <LoadBalancers>

      <LoadBalancer name="FaridaLB">

        <FrontendIPConfiguration type="private" subnet="Subnet-1" />

      </LoadBalancer>

    </LoadBalancers>

   </NetworkConfiguration>

 

6. In the WebRole definition file, reference the load balancer

CSDEF:

<Endpoints>

      <InputEndpoint name="Endpoint1" protocol="http" port="80" loadBalancer="FaridaLB" />

    </Endpoints>