In the previous post, I talked about how we can leverage Logic Apps to create scalable workflows and business processes and demonstrated a process automation example with Salesforce. In this post, we will look at leveraging Logic Apps in a hybrid scenario, where the business process needs to integrate systems in cloud and on-premise.
Hybrid scenarios are becoming commonplace with more enterprise customers taking their first step in embracing cloud by rationalizing part of the portfolio in cloud platforms such as Microsoft Azure. Logic apps can play a significant role in automating business processes that span both cloud-based and on-premise systems.
Azure Service Bus
Connecting an on-premise WCF service to a cloud based platform such as Salesforce is possible using the Azure Service Bus relay feature. Service Bus relay allows you to securely expose a WCF service endpoint in cloud without having to open a firewall connection or making any intrusive changes in the enterprise security infrastructure.
The first step to integrating the on-premise service would be to create a Service Bus namespace (you can create one from the Enterprise Integration menu under create new resource). Once the namespace is created, go to the shared access policies and copy the primary key connection string and the primary key.
Modify your existing WCF service solution by downloading the WindowsAzure.ServiceBus NuGet package as shown below.
This package essentially gets the equivalent relay bindings.
In your service host configuration add the code to expose the service bus end point using the following code:
Modify your WCF service configuration to reflect the WebHttpRelayBinding characteristics.
Create the Client
Now that you have configured your WCF service to expose the service bus end point, you can go ahead and create the client. Since this service needs to be called by Logic Apps, and there is no direct mechanism for Logic Apps to call a SOAP service, you will have to create an Azure Function App, that can call the WCF service whenever Logic App triggers the call. To create the Azure Function App, navigate to add new resource in your Azure management portal and search for Funtion Apps. Provide a name, and a resource group (tip: make sure the resource groups are same between the logic app and funtion app instances). The following figure illustrates:
Once the Function App is created, you can add your client code in the code window. Make sure the necessary NuGet package assemblies are referenced to call the service bus end point.
The final step in the process is to copy the Function URL and put it in the HTTP connector in your Logic Apps workflow created in the previous post. Add this step under the "If Yes" branch whenever an object is modified in Salesforce. You can specify the expected parameters thus configuring the trigger from Salesforce to an on-premise WCF service!