NetTcpRelayBinding

Jun 21, 2016 at 8:18 PM
Edited Aug 5, 2016 at 1:52 PM
Hello, first of all I congratulate you for the excellent work!

I want to define an Endpoint NetTcpRelayBinding of Azure. But NetTcpRelayBinding is not supported.

Thank you!

Example:
        var sh = new ServiceHost(typeof(ProblemSolver));

        #region Local
        sh.AddServiceEndpoint(
               typeof(IProblemSolver), new NetTcpBinding(),
               "net.tcp://localhost:9358/solver");
        #endregion

        #region Azure
        sh.AddServiceEndpoint(
               typeof(IProblemSolver), new NetTcpRelayBinding(),
               ServiceBusEnvironment.CreateServiceUri("sb", "endpoint", "solver"))
                .Behaviors.Add(new TransportClientEndpointBehavior
                {
                    TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "PASSWORK")
                });
        #endregion

        sh.Open();
Aug 5, 2016 at 2:17 AM
Hi,

I have not worked with Service Bus extensively but I think you can configure everything in the config file (if you do not have anything extra). From your code, it looks like you are trying to create a host programmatically. You should be able to create an endpoint configuration that uses the binding and connects to Service Bus without any code. Below is a snipper from one of my previous project. It does not directly provide you with the answer to your netTcpRelay but hopefully it can give you some ideas.
      <serviceActivations>
        <add factory="System.ServiceModel.Activation.ServiceHostFactory" relativeAddress="./ExpenseService.svc" service="AzureWebApp.Services.ExpenseService" />
      </serviceActivations>
 <services>
      <service name="AzureWebApp.Services.ExpenseService" behaviorConfiguration="DefaultServiceBehavior">
        <endpoint name="basicRelayHttpExpenseService" address="" 
                  listenUri="https://sample.servicebus.windows.net/ExpenseService"
                  binding="basicHttpRelayBinding" contract="AzureWebApp.Services.Contracts.IExpenseService"
                  bindingConfiguration="basicHttpRelayEndpoint"
                  behaviorConfiguration="sharedSecretClientCredentials"/>
      </service>
    </services>
You will also need to set a custom endpoint behavior.
      <!-- Service Bus endpoint behavior-->
      <endpointBehaviors>
        <behavior name="sharedSecretClientCredentials">
          <transportClientEndpointBehavior credentialType="SharedSecret">
            <clientCredentials>
              <sharedSecret issuerName="owner" issuerSecret="[Put Your secret key here]" />
            </clientCredentials>
          </transportClientEndpointBehavior>
          <serviceRegistrySettings discoveryMode="Public"/>
        </behavior>
      </endpointBehaviors>
Best Regards
Marked as answer by BigMaster2004 on 8/5/2016 at 5:53 AM