INTEGRATION USING MULE

Integrating Azure Storage with Mule

As integration solutionist, I believe integration software should have no limits and easily connect to different systems regardless of the language it has been built on. Mule whose limits are being tested every day, so far, I feel it fits perfectly in the integration space as a leader. As my recent love towards Azure by gaining some certifications, I wanted to try sending data to Azure storage table from Mule flow.

The first obvious step I took was to look for a Azure Storage Connector in the Anypoint Exchange. I found below connector (https://www.mulesoft.com/exchange#!/microsoft-azure-storage-integration-connector?searchTerm=Azure%20st) which was developed by WISHWORKS. This is a mule certified connector which means it is developed by MuleSoft partners. This also means MuleSoft is not responsible for any updates, bugs fixes regarding this connector. Spending couple hours on this connector, I was stuck at basic step of sending data to Azure Storage as there wasn’t much document available or sample code on this specific need of mine.

I started wondering why worry about this connector and why not write my own connector. Before I jumped into creating a new connector, I realized I had only one day to finish this task and writing a connector which I have never done before will take longer. I now had three options to send data to Azure storage:

  1. Use Azure API
  2. Write custom component and use Azure SDK for Java
  3. Write DotNet code to send data to azure table and call it from Mule flow

I decided to take the third option for two reasons, – a.) First two options were not very appealing to me and b.) I spoke about connecting dotnet code at local meetup and wouldn’t do any good if I shy away from using it. What better way to test the .Net connector and also put my previous blog about debugging .net code in practice here.

Below are the steps which I took to get this thing working:

Step1: Write .Net code for sending data to Azure Storage

There are tons of examples how to do it and below is the code I used in my application:

Step2: Using MuleSoft .Net connector

In this step, you will have to use .Net connector and drop in the flow. There are two versions of dotnet connectors – Standard and Select. You will need license to use select and if you have one, I would suggest to use that than the standard version as the select version comes with MuleSoft support. In this post, I am going to use the standard version. To include it as a maven dependency, add below dependency:

[xml] <dependency>
<groupId>org.mule.modules</groupId>
<artifactId>dotnet-connector</artifactId>
<version>2.0.1</version>
</dependency>
[/xml]

You can install the dotnet connector by Help -> Install New Software:

 

Once dotnet connector is installed, you can now configure the connector by selecting the path of dll and the method to be called.

Step3: Test it out

The final step really is to test your application. If you have any issues with refreshing metadata try restarting anypoint studio and also make sure dotnet method is defined as public.

With this, I was able to do what I wanted to in less than 1hr and get going with other integrations in my application. I now not have to rely on connector written by a third party and can customize DotNet code to use it to fit my imagination.