我想在Azure托管的Service Fabric群集和我的专用网络之间设置Azure Service Bus Relay。
我无法通过Service Fabric WCF服务获得Service Bus Relay的配置。
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;
})
};
}
答案 0 :(得分:0)
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;
})
};
}