Home © Rinat Abdullin 🌟 AI Research · Newsletter · ML Labs · About

Redirect Tcp Connections in Windows Azure

I've just published a quick and extremely simple open source project that shows how to redirect TCP connections from one IP address/port combination to another in Windows Azure. It is sometimes helpful, when dealing with SQL Azure, cloud workers, firewalls and the like.

Lokad Tcp Tunnel for Windows Azure | Download

Usage is extremely simple:

  • Get the package.
  • Configure ServiceConfiguration to point to the target IP address/port you want to connect to (you can do this later in Azure Developer's Portal).
  • Upload the Deployment.cspkg with the config to the Azure and start them.
  • Connect to deployment.cloudapp.net:1001 as if it was IP:Port from the config.

If you are connecting to SQL Server this way (hosted in Azure or somewhere else), then the address have to specified like this in Sql Server Management Console (note the comma):


Actual Azure Worker config settings should look similar to the ones below, when configuring TCP Routing towards SQL Server (note the 1433 port, that is the default one for SQL):

  <Setting name="Host" value="ip-of-your-SQL-server" />
  <Setting name="Port" value="1433" />

The project relies on rinetd to do the actual routing and demonstrates how to:

  • Bundle non .NET executable in Windows Azure Worker and run it.
  • Deal with service endpoints and pass them to the processes.
  • Use Cloud settings to configure the internal process.

Since core source code is extremely simple, I'll list it here:

var point = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Incoming"];
var host = RoleEnvironment.GetConfigurationSettingValue("Host");
var port = RoleEnvironment.GetConfigurationSettingValue("Port");

var tempFileName = Path.GetTempFileName();
var args = string.Format(" {0} {1} {2}", point.IPEndpoint.Port, host, port)

File.WriteAllText(tempFileName, args);

var process = new Process
    StartInfo =
        UseShellExecute = false,
        RedirectStandardOutput = true,
        RedirectStandardError = true,
        CreateNoWindow = true,
        ErrorDialog = false,
        FileName = "rinetd.exe",
        WindowStyle = ProcessWindowStyle.Hidden,
        Arguments = "-c \"" + tempFileName + "\"",
    EnableRaisingEvents = false


Tcp Tunnel for Azure is shared by Lokad in hopes that it will save a few hours or a day to somebody.

Published: August 25, 2010.

🤗 Check out my newsletter! It is about building products with ChatGPT and LLMs: latest news, technical insights and my journey. Check out it out