设置用于服务总线中继绑定的Azure Service Fabric侦听器 [英] Setup a Azure Service Fabric Listener for Service Bus Relay Binding
本文介绍了设置用于服务总线中继绑定的Azure Service Fabric侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Azure中托管的Service Fabric群集和专用网络之间设置Azure Service Bus中继.
I want to setup a Azure Service Bus Relay between my Service Fabric cluster hosted in Azure and my Private Network.
我无法从Service Fabric WCF服务获得服务总线中继的配置.
I can't get the configuration of the Service Bus Relay to work from a Service Fabric WCF service.
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new[]
{
// Standard WCF Listener
new ServiceInstanceListener(context =>
new WcfCommunicationListener<IFooService>(
wcfServiceObject: this,
serviceContext: context,
endpointResourceName: "WcfServiceEndpoint",
listenerBinding: WcfUtility.CreateTcpListenerBinding()
)
),
// Service Bus Relay Listener
new ServiceInstanceListener(context =>
{
var wcfRelay = new WcfCommunicationListener<IFooService>(
wcfServiceObject: this,
serviceContext: context);
wcfRelay.ServiceHost.AddServiceEndpoint(
typeof(IFooService),
new NetTcpRelayBinding(),
ServiceBusEnvironment.CreateServiceUri(
"sb",
"{mynamespace}.servicebus.windows.net",
"{myservce}"))
.Behaviors.Add(new TransportClientEndpointBehavior
{
TokenProvider =
TokenProvider.CreateSharedAccessSignatureTokenProvider(
"RootManageSharedAccessKey",
"{mykey}")
});
return wcfRelay;
})
};
}
推荐答案
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new[]
{
new ServiceInstanceListener(context =>
{
var listener = new WcfCommunicationListener<IFooService>(
serviceContext: context,
wcfServiceObject: new FooService(),
listenerBinding: new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None,RelayClientAuthenticationType.None),
address: new EndpointAddress( ServiceBusEnvironment.CreateServiceUri("https","[ServiceBusNamespace]","[RelayEndPoint]"))
);
var ep = listener.ServiceHost.Description.Endpoints.Last();
ep.EndpointBehaviors.Add(
new TransportClientEndpointBehavior()
{
TokenProvider = TokenProvider.CreateSharedSecretTokenProvider("owner","[issuerSecret]")
});
ep.EndpointBehaviors.Add(
new ServiceRegistrySettings(discoveryType:DiscoveryType.Public));
ep.EndpointBehaviors.Add(new WebHttpBehavior());
return listener;
})
};
}
这篇关于设置用于服务总线中继绑定的Azure Service Fabric侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文