Your first simple Windows Azure BizTalk Service implementation
Ok, enough of the setting up and configuring already! Let’s go down to business and create your very first, simple, integration in WABS….
What we will do is to create a Bridge (I’ll get back to the term Bridge shortly), that picks up text files from an FTP location and sends them to another location.
Gathering all your credentials to get started
The first then we will do is pick up all the stuff we collected in my first two blogs about WABS, you will need the following:
- The name of your WABS
- The WABS ACCESS CONTROL NAMESPACE (Found in the WABS Dashboard)
- The DEFAULT ISSUER and DEFAULT KEY (Found in the WABS CONNECTION INFORMATION).
- The SSL Certificate (Can be downloaded from the WABS Dashboard)
Test your credentials from your developing environment
With these things in place, we will now test that everything is working and that all credentials are in place, before we will start working in Visual Studio.
To do that we will use PowerShell.
- On your development environment where we installed the WABS SDK, open PowerShell in Administrator mode.
- Execute the following command to load the WABS module:
import-module “C:\Program Files\Windows Azure BizTalk Services Tools\Microsoft.BizTalk.Services.Powershell.dll”
The WABS module should now be loaded, take a look at the commands available by executing the following:
get-command -module Microsoft.BizTalk.Services.PowerShell
Now let’s load all of our credentials into variables for re-usability.
$acsns = ‘Your ACS Namepsace‘
$in = ‘The Issuer Name (most likely owner)’
$ik = ‘The Issuer Key‘
$du = ‘https://WABSName.biztalk.windows.net/default’
Now try to execute the following command, to get a list of all bridges deployed in your WABS:
Get-AzureBizTalkBridge –AcsNamespace $acsns -IssuerName $in -IssuerKey $ik –DeploymentUri $du
You should now see the following error:
what the error is saying is that the HTTPS address it is trying to communicate with is using a certificate that is not trusted (the certificate is not issued by a trusted authority, since it is a default self-signed certificate made when we setup the WABS).
To resolve this issue, we will use the .cer file we exported earlier and store it in the following certificate store (Local Machine / Trusted Root).
In PowerShell execute the following command (replace your file path and name of the certificate if needed):
Import-Certificate -FilePath C:\cert\verticablog.cer -CertStoreLocation Cert:\LocalMachine\root
With this in place, try executing the Get-AzureBizTalkBridge command from above, you should now get no errors (and no bridges, since nothing is deployed yet).
Creating our first bridge.
With all our credentials in place, open Visual Studio and create a new BizTalk Services project (Found under C#, when creating a new project).
For this project, you will need an FTP Server with two folder (In and Out) and a username and password that has sufficient permissions to access, read, write and delete from the folders.
Once created you should see a Toolbox and a Canvas similar to this:
Let us create our first FTP Source then. An FTP Source is a source that polls files from an FTP folder and sends them to a bridge (we will talk about bridges in a moment).
- From the Toolbox, choose an FTP Source, and drag it onto the Canvas in the left side.
- Under properties configure your FTP Source similar to this screenshot (replacing when needed).
Now let us create a bridge, that the source can send its documents to.
A bridge is an artifact in WABS, used for routing and transforming messages. A bridge can have multiple sources and multiple destination, but each message passing through a bridge can only be sent to one destination.
- From the Toolbox drag a Pass-Through Bridge to the right side of your FTP Source.
- Under Bridge Properties change both Entity Name and Relative Address to PassBlogBridge.
- From the Toolbox choose the Connector and connect the FTP Source with the left side of the bridge. (It takes a bit of practice to do this, in general you need to catch the red dots on both the source and the target).
This bridge will be extremely simple doing nothing but passing the file through to a destination (also FTP). Later on we will look at much more sophisticated bridges and routing mechanisms.
We will now create an FTP destination pointing at our Out folder.
- From the Toolbox choose FTP Destination, and drag it to the canvas on the right side of the bridge.
- Configure the destination as follows (change when needed):
- Now connect your bridge with the destination, using the Connector from the Toolbox.
- Select the newly created connection and select Filter Condition found under Properties.
- Choose Match All and click OK. (This means that all messages received in the bridge will be sent to this particular destination).
- Select Route Action and click Add.
- Configure the Routing Action as follows (note: this hard codes the file name for the destination file to BlogOutput.txt, and is not a proper approach for anything than this simple demo, since it requires us to delete a file before we can send an additional file).
Deploy the solution.
With this in place, we are ready to deploy the bridge and the FTP source to our WABS.
- Build your solution to verify that everything can compile.
- Click somewhere on your canvas where there are no artifacts, so that the canvas properties appear.
- Change the BizTalk Service URL servicename to the name of your WABS.
- Right click your project and choose Deploy.
- You will now be prompted for the ACS namespace and your Issuer Key (called Shared Secret here).
- Type the appropriate values and click deploy (leave the check box unchecked).
If the deployment was successful, you should see a Deploy: 1 succeeded…. in your Output windows.
Starting the Source
Note that when we configured the FTP Source, we set the Initial Status to Stop. We now need to manually start it, to do this we will, again, use PowerShell.
- If you closed your PowerShell before, open it again, load the module and set the credential variables.
- Verify that your bridge is now deployed:
Now type the following to show the Source connected to our Bridge:
Get-AzureBizTalkBridgeSource –AcsNamespace $acsns -IssuerName $in -IssuerKey $ik –DeploymentUri $du -bridgepath PASSBLOGBRIDGE
Notice that the Status is False (means that the source is stopped).
We now need to start it:
Start-AzureBizTalkBridgeSource –AcsNamespace $acsns -IssuerName $in -IssuerKey $ik –DeploymentUri $du –BridgePath PASSBLOGBRIDGE
You should see the following output: All the source in the pipeline………have been started.
Test the solution
With our Source started, all that is left to do is to create a non-empty text file and copy it to your FTP In folder. Within 15 seconds, the files should be removed and a file named BlogOutput.txt should appear in the Out folder.
Note: If the file is not removed, you have likely misspelled something when setting up either your source or destination. You will the need to go to the WABS Portal (Select MANAGE in the Azure Portal, when your WABS is selected), and examine errors in TRACKING.
Stay tuned for more complex Bridges, mapping and submitting to bridges using REST instead of the need for an FTP Source.