Tuesday, December 14, 2010

Biztalk and the Cloud

I was in NY city on Dec 1 for the Azure Firestarter event at the Microsoft Office. It was a nice overview of Azure. For past year or so, I have been thinking of getting my hands dirty with this technology. Between work and family, never really got a chance to do so. But this time, after the event I promised myself to actually put what I learnt into practice. Moreover so, because the free registration to Azure portal would expire in few weeks time.

So, I came up with a simple scenario.

1. Expose a CreditScore service using Biztalk within a firewall.
2. Publish this Biztalk Orchestration as WCF to Cloud Endpoint using WCF publishing
3. Use a simple windows client application to send a message and receive a reply from this Biztalk service exposed within firewall.

Step 1:

Create a two way Biztalk Orchestration that accepts an xml message(First Name, Last Name, SSN) and returns a message (Credit Score and Comments).

(Image 1)

Step 2.

Publish this Orchestration as the cloud endpoint.


1. Biztalk 2010
2. Windows AppFabric SDK 1.0
3. Windows Azure AppFabric Account to create the URL of cloud Endpoint (Free, if you have MSDN subscription)
4. Biztalk 2010 adapter pack

For details checkout : support.microsoft.com/kb/2449478

Step 2. Create a windows client to test this Biztalk service using endpoint exposed in the cloud.

Pre-Requisite for the client machine:

1. Visual Studio(2008 sp1 or 2010)
2. Azure AppFabric SDK 1.0 (to get NetTcpRelayBinding and TransportClientEndpointBehavior).

a) Open a "Windows Form Application" Project
b) Add Reference to "Microsoft.ServiceBus.dll" from location

"C:\Program Files\Windows Azure AppFabric SDK\V1.0\Assemblies\NET3.5\Microsoft.ServiceBus.dll"

c)Add Service Reference point to the URL exposed in the cloud : Sample URL:

shashiraina-demo.servicebus.windows.net/Test.Biztalk.Cloud.Orch/. This namespace in URL is created using AppFabric Account. (Image below)

(Image 2)

d) Use the proxy to generate client side objects. I used code instead of config file because, I was not able to get "TransportClientEndpointBehavior" and "NetTcpRelayBinding" to show up in Config file. This may be because I was just using a Windows Application as test client instead of "cloud" supported client. With code, I could easily use the ServiceBus namespace and get it working.

Sample client code is below:

GetCreditScore.GetCreditScoreRequest req = new GetCreditScoreRequest();
GetCreditScore.GetCreditScoreResponse res = new GetCreditScoreResponse();
NetTcpRelayBinding tcpRelayBinding = new NetTcpRelayBinding();
TransportClientEndpointBehavior clientEndBeh = new TransportClientEndpointBehavior();
clientEndBeh.CredentialType = TransportClientCredentialType.SharedSecret;
clientEndBeh.Credentials.SharedSecret.IssuerName = "owner";
clientEndBeh.Credentials.SharedSecret.IssuerSecret = "Extract this from Appfabric Portal";// (it will look something like the crossed out section in the Image 2" )
EndpointAddress endpoint = new EndpointAddress("sb://shashiraina-demo.servicebus.windows.net/Test.Biztalk.Cloud.Orch/WcfService_Test_Biztalk_Cloud_Orch.svc");

WcfService_Test_Biztalk_Cloud_OrchClient client = new WcfService_Test_Biztalk_Cloud_OrchClient(tcpRelayBinding, endpoint);

req.Score = new Score(); ;
req.Score.FirstName = "Shashi";
req.Score.LastName = "Raina";
req.Score.SSN = "123-234-2323";

res.Root = new Root();
res.Root = client.GetCreditScore(req.Score);

Response from the service is below: (Go Ahead and tried it out from your machine)!

Image 3

So, without punching a hole in your DMZ, you could expose your Biztalk services to outside world. I have been involved in complex configurations in ISA reverse proxy to expose Biztalk services to outside world. But using "Appfabric Connect for Services" , all these complex configurations can be eliminated. Moreover, the ACS (Access Control Services) that is part of Azure Appfabric allows creating your own plug-in security framework.


Anonymous said...

This is very helpful.I was facing same issue while trying to run a sample cloud application.

mettlus said...

Why not using Biztalk Event Bus on the Cloud aka ESB