Q:

Is it possible to create azure service bus relay using Windows Service application?

I have a windows service bus relay application running in console application. Initially I created using console app for testing. Now I have a requirement to convert this console application to windows service. All the Azure documentation only show examples with console application. 
Is there is a way to create the service bus relay application using windows service, so that in my client side I don't need to run this console application(as a command prompt). 
I am trying to connect cloud application to corporate/ secured network. 

Created a new MVC web application to talk to relay service. Not sure what I am missing. Is there is any changes I need to do in "MyRelayTestService" config file. 
using Microsoft.ServiceBus;
using System.ServiceModel;
using System.Web.Mvc;
using WCFRelay;

namespace TestRelayApplication.Controllers
{
    public class HomeController : Controller
    {
        static ChannelFactory<IRelayTestChannel> channelFactory;

        public ActionResult Index()
        {
            var tcpbinding = new NetTcpRelayBinding();
                    channelFactory = new   ChannelFactory<IRelayTestChannel>(tcpbinding, "yourServiceNamespace");
            channelFactory.Endpoint.Behaviors.Add(new   TransportClientEndpointBehavior
            {
                TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "yourKey")
            });
            using (IRelayTestChannel channel = channelFactory.CreateChannel())
            {

                var testStr = channel.DoWork();  // error on this call           
            }

            return View();
        }
    }
}

Error:

A:

Is it possible to create azure service bus relay using Windows Service application?

Yes, We can do that using Windows Service. I do a demo for it. The following is my detail steps.
1.Create a Relay namespace using the Azure portal,we can get more info from official document. And create WCF Relay on the Azure portal.

2.First Module: WCF Service Library (WCFRelay.dll)
Definition of Service Contract
  [ServiceContract]
    public interface IRelayTest
    {
        [OperationContract]
        string DoWork();
    }

Implementation of Service Contract
public class RelayTest : IRelayTest
    {
        public string DoWork()
        {
            return "hello";
        }
    }

Second Module: Create WCF Relay Windows Service and reference the created WCFRelay.dll

Implement the OnStart and OnStop  for the service
public partial class MyRelayTestService : ServiceBase
    {
        ServiceHost m_svcHost = new ServiceHost(typeof(RelayTest));
        public MyRelayTestService()
        {
            InitializeComponent();
        }
    protected override void OnStart(string[] args)
    {
       // m_svcHost?.Close();
        ServiceHost sh = new ServiceHost(typeof(RelayTest));
        var binding = new WebHttpRelayBinding {IsDynamic = false};
        var serviceRegistrySettings = new ServiceRegistrySettings(DiscoveryType.Public);
        sh.AddServiceEndpoint(
           typeof(IRelayTest), binding,
           ServiceBusEnvironment.CreateServiceUri("sb", "namespace", "path")) //tomtestrelay , testtom
            .Behaviors.Add(
            new TransportClientEndpointBehavior
            {

                TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "Key value")
            }
            );

        sh.Open();
    }

    protected override void OnStop()
    {
        if (m_svcHost == null) return;
        m_svcHost.Close();
        m_svcHost = null;
    }
}

5.Adding an installer to the Service

Add following code:
public ProjectInstaller()
            {
                // InitializeComponent();
                serviceProcessInstaller1 = new ServiceProcessInstaller { Account = ServiceAccount.LocalSystem };
                serviceInstaller1 = new ServiceInstaller
                {
                    ServiceName = "WinServiceRelayTest",
                    DisplayName = "WinServiceRelayTest",
                    Description = "WCF Relay Service Hosted by Windows NT Service",
                    StartType = ServiceStartMode.Automatic //set service start automatic
                };
                Installers.Add(serviceProcessInstaller1);
                Installers.Add(serviceInstaller1);
            }

6. Install Service 
Navigate to the installutil.exe in your .net folder, more details please refer to another SO thread.
Install : "C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "c:\yourservice.exe"
uninstall : "C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" /u "c:\yourservice.exe"

Check the Windows Service status

If the service can't start as expected, please check the Event viewer to get the detail exception info. Then uninstall and reinstall again.

Check from Azure Portal, we can get the listener has been changed to 1.

