Service Bus Relay
  • 18 Jan 2019
  • 5 Minutes to read
  • Contributors
  • Comment
  • Dark
    Light
  • PDF

Service Bus Relay

  • Comment
  • Dark
    Light
  • PDF

Article Summary

This section will discuss the Azure Service Bus Relay and where it fits within the Microsoft Integration technology stack.

What is it?

The Azure Service Bus Relay is a technology which is aimed at helping you to create hybrid integration solutions where one you would bridge from a client outside of your organisation to access a service inside your network.

Azure Service Bus Relay is conceptually like a router hosted in the cloud. If you implement an on premise service then that service can “come online” and open an endpoint which is hosted in the cloud on the Azure Service Bus Relay. You can then allow a client application to access this endpoint and make web service calls to it which are then routed down to the service implementation which is hosted on premise. Your service would then implement the functionality it normally would.

The below picture shows you an example of how Dynamics CRM could be calling a service hosted on the Azure Service Bus Relay.

image.png

Azure Service Bus Relay actually has 2 core features:

WCF Relays

WCF Relays use the WCF protocol to allow you to reach across networks via the relay from a WCF client to the WCF service. WCF relays have been around for a long time and are reliable and a very well subscribed service on Azure with lots of users.

Hybrid Connections

Hybrid Connections use open standard web sockets to create their relay capabilities which allows them to open up multiple scenarios using different protocols. While WCF relays can only be used with .net framework and WCF, hybrid connections support .net core, other languages such as javascript, NodeJS and other back end service protocols.

How does it bridge into my organisation?

The Azure Service Bus Relay uses a port forwarding technology which allows your on premise service to open up an outbound bi-directional connection from your on premise server to the cloud.. The relay is then able to forward requests back down that bi-directional channel to your on premise service.

The fact that the connection to the cloud from on premise is initiated on premise and is outbound means that you do not need to expose any inbound ports through your organizations firewall which increases the security.

What about Security

The Azure Service Bus Relay uses transport level security with SSL to secure data over the wire over https or net/tpc protocols for WCF. The Azure Service Bus Relay uses shared access secrets which are provided by the Azure portal. These secrets allow you to have a different secret for senders, receivers and manage permissions related to the relay.

Do I have to host the receiver service on premise?

No you don’t, the receiver service can be hosted anywhere as long as it can access the internet to register itself on the endpoint. Example receivers could be:

WCF Relay:

  • An Azure App Service with a WCF receiver configured to use the Service Bus bindings
  • An on premise IIS application
  • An on premise windows service
  • An Azure Web Job which has opened a listener to the Service Bus
  • A custom .net application using WCF

Hybrid Connections:

  • An Azure App Service with a in other languages
  • An on premise windows service
  • An executable written in a different language
  • An Azure Web Job which has opened a listener

The receiver can be in your own data centre, in Azure or in another cloud provider.

How does load balancing work?

Load balancing works using a competing consumer pattern where messages are routed across the receivers which are currently listening. One service instance will receive one copy of the message. You do not need any special on premise routing software or hardware.

Costs

The costs for Azure Service Bus Relay follow a pay as you go model.

  • You would pay per hour for each listening service instance
  • For WCF Relay you would also per message for each message flowing through the relay
  • For hybrid connections you would pay a small amount per GB of data

Obviously the costs depend on how much you use it and on real world projects we have found that unless you are a pretty high volume user the Azure Service Bus Relay tends to be one of the lowest cost options for connecting cloud to on premise in terms of setup and running costs.

The following technologies can be combined with Azure Service Bus Relay when creating solutions.

BizTalk

In BizTalk you can create a receive location which uses the WCF relay bindings which allows you to open up an endpoint on the Azure Service Bus Relay which allows BizTalk to receive messages via the cloud. This can be a great low cost way to bridge from outside of your organisation to your existing BizTalk infrastructure by sending messages through the WCF Relay.

WCF Routing Service

If you have existing on premise web services and want to expose them to the cloud without having to make any changes to allow them to use the WCF relay bindings then one great way you can do this is to use the WCF Routing Service along side Azure Service Bus Relay. Your instance of the WCF Routing Service would come online and register an endpoint in the Azure Service Bus Relay. When a message is send through the cloud to your on premise WCF Routing Service it will inspect the SOAP Action and use some routing rules to forward the message to another WCF Service somewhere else on premise.

This is an easy way to span out to the cloud for an existing application potentially without having to implement any changes.

Service Bus Relay can be one of the easiest services on Azure for customers wanting to start a hybrid capability. You can get up and running very quickly with WCF Relay and Hybrid Connections to allow services outside the organisation connect to your on premise services in a scalable yet secure way.

We have found in practice many projects which used relay as an accelerator to get to the cloud were also able to use it in production rather than the overhead of some of the alternative choices such as VPN's and others.

Recommendation
Service Bus Relay is a green light and can be an accelerator to help you get to the cloud. I would have a little bit of caution surrounding WCF relay inline with the WCF product lifecycle but I dont think this is a big concern and its certainly possible to bridge from Web API to WCF's flavour of REST if you wanted to go via the relay for REST services.

Learn More

The following articles have good resources for Service Bus Relay:


Was this article helpful?