I have an Azure Virtual Machine running, and I have the following logic in a Windows Service that I coded up that hosts a WCF TCP endpoint with a MEX HTTP endpoint as well:
private void OpenTCPChannel()
{
string fqdn = System.Net.Dns.GetHostEntry("localhost").HostName;
NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, true);
binding.SendTimeout = new TimeSpan(0, 1, 0);
binding.ReceiveTimeout = new TimeSpan(0, 1, 0);
binding.MaxReceivedMessageSize = int.MaxValue;
binding.MaxConnections = int.MaxValue;
binding.ListenBacklog = int.MaxValue;
binding.ReliableSession.Enabled = true;
binding.ReliableSession.Ordered = true;
binding.ReliableSession.InactivityTimeout = new TimeSpan(0, 1, 0);
Uri serviceAddress = new Uri(String.Format("net.tcp://{0}:{1}/GameServer", fqdn, Properties.Settings.Default["GameServerPort"]));
ServiceHost serviceHost = new ServiceHost(service, serviceAddress);
serviceHost.AddServiceEndpoint(typeof(IGameService), binding, serviceAddress);
ServiceMetadataBehavior metadataExchange = new ServiceMetadataBehavior();
metadataExchange.HttpGetEnabled = true;
metadataExchange.HttpGetUrl = new Uri(string.Format("http://{0}:{1}/GameServer", fqdn, Properties.Settings.Default["MEXPort"]));
serviceHost.Description.Behaviors.Add(metadataExchange);
serviceHost.Open();
log.WriteEntry(String.Format("Successfully started TCP endpoint at {0}.", serviceAddress.ToString()));
log.WriteEntry(String.Format("Successfully started MEX endpoint at {0}.", metadataExchange.HttpGetUrl.ToString()));
}
The code runs perfectly well when I test locally, but when I run my service and open my TCP channel on my Azure VM, I can't access my MEX endpoint for some reason.
I'll try navigating to: http://<MyServiceName>.cloudapp.net:<MEXPort>/GameServer
but I can't grab a service reference from that address. Is there something that I've missed in terms of how to provision an Azure VM to allow tunneling out from a local port to the outside world?