Search code examples
azureazure-cloud-services

How to access an Azure Cloud Service (Web Role) instance through its private IP?


Ive got an Azure Cloud Service with a couple of instances in a load balanced setup.

For specific reasons, I would like to access the website running on the first instance. Typing its private IP address in the browser doesnt get my anywhere, neither does using its public address, because it should go through the load balancer.

Is there a way to acess the first instance, perhaps by using a virtual network?

My idea is to:

  • Create a Virtual Network
  • Add the Cloud Service to the Virtual Network
  • Create an Azure VPN Gateway for this network
  • Set up a client on my development computer, so that I can access the instance through the VPN Gateway

Is the above possible, do I need to do something specific to add a Cloud Service to a VNet?


Solution

  • First create a Virtual Networks (Classic) using Azure portal as follows:

    Example: Vnet=> chepravnet=10.3.0.0/16 subnet=> cscubnet=10.3.1.0/24

    Now, add a site-to-site VPN connection to your network as shown below:

    enter image description here

    And modify your ServiceConfiguration.cloud.cscfg accordingly and publish your cloud service:

    <NetworkConfiguration>
    <VirtualNetworkSite name = "chepravnet" />
    <AddressAssignments>
      <InstanceAddress roleName = "WebRole1">
        <Subnets>
          <Subnet name = "CSsubnet" />
        </Subnets>
      </InstanceAddress>
      <InstanceAddress roleName = "WorkerRole1">
        <Subnets>
          <Subnet name = "CSsubnet" />
        </Subnets>
      </InstanceAddress>
    </AddressAssignments>