BizTalk SFTP adapter: “Unable write file”

Since recently my SFTP send port for some reason couldn’t write any files to the configured SFTP folder anymore. The error information displayed on the suspended instances was:

An unexpected failure occurred while processing a message. The text associated with the exception is “[SftpTransmitterEndpoint] Unable to transmit file sftpfolder/51D8D887-DB21-4675-8EA2-927B86F84CF3.
Inner Exception:
Unable write file to sftpfolder/51D8D887-DB21-4675-8EA2-927B86F84CF3
Unable to connect to Sftp host [sftpHost]. Changing any Send Port Transport properties might require the host to be restarted, as the connection pool might still have connections”.

In the event viewer there were a bunch of error events logged coming from the SFTP adapter.

EventVwr

The events stated some different error messages like:

Method: Blogical.Shared.Adapters.Sftp.SharpSsh.Sftp.CheckHostKey
Error: HostKey does not match previously retrieved HostKey.

Method: Blogical.Shared.Adapters.Sftp.SharpSsh.Sftp.connect
Error: Unable to connect to Sftp host [mpm01.uat.vvm.addelijn.be]

Method: Blogical.Shared.Adapters.Sftp.SharpSsh.Sftp.Put
Error: Unable write file to sftpfolder/62EFCE4A-8BFE-428B-B4E4-4B43A9B35075

Method: Blogical.Shared.Adapters.Sftp.SftpTransmitterEndpoint.ProcessMessage
Error: [SftpTransmitterEndpoint] Unable to transmit file sftpfolder/62EFCE4A-8BFE-428B-B4E4-4B43A9B35075.
Inner Exception:
Unable write file to sftfolder/62EFCE4A-8BFE-428B-B4E4-4B43A9B35075
Unable to connect to Sftp host [sftpHost]. Changing any Send Port Transport properties might require the host to be restarted, as the connection pool might still have connections

A message sent to adapter “SFTP” on send port “SP_Employee.Messaging_Whitelist” with URI “SFTP://sftpHost:22/sftpfolder/%SourceFileName%” is suspended.
Error details: An unexpected failure occurred while processing a message. The text associated with the exception is “[SftpTransmitterEndpoint] Unable to transmit file sftpfolder/62EFCE4A-8BFE-428B-B4E4-4B43A9B35075.
Inner Exception:
Unable write file to sftpfolder/62EFCE4A-8BFE-428B-B4E4-4B43A9B35075
Unable to connect to Sftp host [sftpHost]. Changing any Send Port Transport properties might require the host to be restarted, as the connection pool might still have connections”.
MessageId: {E5D8FDDE-7246-484C-82B2-335B171BB8F0}
InstanceID: {D3E33013-9250-4750-9B4B-68926601D7FD}

How to solve the issue?

It was the info ‘HostKey does not match previously retrieved HostKey’ that got me thinking. And finally also provided me with the solution.
To overcome this issue, I located the hostkey that was saved and simply removed the hostkey.

Follow these steps to solve this issue

  1. locate the SftpHostFiles.config file. It can be found under something like ‘C:\Users\[BTSUser]\AppData\Local\IsolatedStorage\abwnobui.3i0\ipehwsgb.i2y\Url.hxlzol3fqigkmb3hbeb4siqcmd5vjau2\AssemFiles’
  2. Edit the config file and remove the node containing the  SFTP Host that you are trying to connect to, and save the config file.
  3. Restart the host instance

This should suffice to have a working solution again.

Hope this will help you out.

Using key file authentication with the BizTalk SFTP adapter

Authentication on an SFTP location can be done with simple username/password credentials… However another way to authenticate the sender is by using a Key Authentication file. But how can this last authentication method be used inside the BizTalk SFTP adapter?

the BizTalk SFTP adapter we used to achieve this is the  freely available SFTP adapter on Codeplex. Just download the adapter and install it. And don’t forget to add the adapter in the BizTalk admin console of course.

Now then let’s set up the port in BizTalk. In my example I ‘ve configured a receive location, but obviously the same goes for the send port configuration.
First of all choose the created adapter in the biztalk admin console, as shown below.

Port configuration

To set up the proper configuration for the SFTP port, just press the ‘Configure’-button.

Configure

These parameters need to be set:

  • Schedule: define a timely schedule how often you want to poll the SFTP location (receive location only)
  • File Mask: set the correct file mask
  • SSH Host: the host address of the SFTP location
  • SSH Identyfile: Select the Key authentication file on disk
  • SSH Identyfile Passphrase: the password of the selected key authentication file
  • SSH Remote Path: the path on on the SFTP location
  • SSH User: the user name to authenticate on the SFTP location

Seems pretty straight forward, doesn’t it?
Well there are some things you ‘ll need to take into account to make sure the connection can be made…

Make sure the identyfile type is supported

You’ll need to make sure the identyfile type is supported by the library. The supported versions can be found here. As this is the library which is used by the bizTalk SFTP adapter.

Make sure the identyfile can be recognized

In my case for example, I got an *.ppk file as authentication file. But as it turned out, this wasn’t recognized.
The error message you git is this:

invalid privatekey: D:\tempkey.ppk

Which in the end seemed a bit misleading, as the problem wasn’t the private key for the authentication file. It was just the *.ppk file that wasn’t supported.
To make the key authentication file working, I had to convert the file to an OpenSSH key file. This can be done by using PuttyGen for example, and exporting the authentication file as an OpenSSH key file.

Don’t use both password parameters

Also make sure you only use the intended parameter SSH Identyfile Passphrase, and leave the SSH password blank.
In case both password fields are filled, the SFTP adapter will try to authenticate by the username/password credentials stated. So it won’t offer the specified identyfile to authenticate.

How do you handle the BizTalk deployment?

For the deployment of BizTalk applications we use a custom made tool within our company. We were curious to have some feedback from the community on the deployment of BizTalk applications. How do you handle the biztalk deployments at your company?

Our deployment manager tool is based on the idea to store all used objects in a database model (BizTalk artifacts, but also stuff like MSMQ, file locations, SQL objects, etc. …). Most of these objects are added using auto discovery of the BizTalk databases, so manually adding of objects is reduced to a minimum. Above all, BizTalk artifacts can have a different configuration (binding) defined per environment (test, dev, prod, …).
It also allows you to define all dependencies. Again most of these dependencies will be defined by the tool automatically.
This way of working makes it possible for the tool to define which actions need to be taken to deploy a certain application (or just a part of the application or only some objects). The deployment manager tool will define which objects need to be removed and redeployed (also unenlisting/disabling and starting/enabling artifacts will be done by itself). As a result, using the tool will allow us to deploy much faster, because the objects to redeploy are reduced to an absolute minimum and no complete redeploy is needed (like BizTalk Deployment framework does for example).

Another very useful and much used functionality is the possibility to define complete business/functional flows, including some generic components. This makes sure you can also deploy or redeploy a complete (new) flow (like an order flow for example) by itself, including all necessary objects (receive and send ports, file locations, etc. …).

The deployment can be done cross BizTalk applications. So the separation in applications is no longer deployment dependent.

The most important part is to set the database model correct and keep it this way… this will guarantee a much easier and faster deployment, where each environment has its own version of the current deployed objects.

 

Please answer following questions:

  1.      Is your BizTalk deployment automated (BizTalk deployment framework, custom scripting with MSBuild or BTSTask, powershell scripts, etc. …), or do you just do manual deployment using MSI and binding files?
  2.        Which deployment tools or scripts are you using, or have you used before? And what are your thoughts of these tools (benefits and complaints)?
  3.        What do you think of a tool like our custom deployment manager tool (using autodiscovery, etc. …)?

Thanks for your replies.

BizTalk error: ‘The message found multiple request response subscriptions’

Problem

When trying to send a message to multiple request response ports you can receive the following error in BizTalk:

The message found multiple request response subscriptions. A message can only be routed to a single request response subscription.

Error

Solution

First of all, you’ll need to reconsider if it’s architecturally sound to route a message to two request response ports? if yes, read further

Pre-BizTalk 2010

hot fix available at location http://support.microsoft.com/kb/923632

BizTalk 2010

1) Inside the BizTalk administration console open the BizTalk Settings Dashboard

Open

2) Go to the tab for the hosts settings, and select the host used by the request response ports.

DB

3) Check the checkbox for property Allow Multiple Responses

Setting

 

DocumentSpecName usage in the pipeline configuration

A schema can be defined in the ‘DocumentSpecName’-attribute of the pipeline configuration properties (in the dissamble stage).
When no schema is defined and there are multiple schema’s with the same combination for ‘Target Namespace’ (optional) and ‘Root Name’, you ‘ll get following error in the receive pipeline:

There was a failure executing the receive pipeline: “<ReceivePipeline>” Source: “XML disassembler” Receive Port: “<ReceivePortName>” URI: “<URI>\*.xml” Reason: Cannot locate document specification because multiple schemas matched the message type “<TargetNameSpace><RootName>”.

The use of “DocumentSpecName” attribute in the configuration section of the pipelines is there to direct the pipeline to validate the message against a specific schema in the given assembly. The attibute should be filled with the schema full name (‘<schema type>, <schema assembly>’) as shown in below figure. This should solve the above error.

However, the issue becomes more complex when using a schema with multiple root nodes. For this situation you’ll get following error:

There was a failure executing the receive pipeline: “<ReceivePipeline>” Source: “XML disassembler” Receive Port: “<ReceivePort>” URI: “<URI>\*.xml” Reason: No Disassemble stage components can recognize the data .

What BizTalk wants to tell us is that at this stage the well known syntax of “<schema type> ,<schema assembly full name>” in the ‘DocumentSpecName’-attribute is not enough for multipart schemas.

For multipart schemas an additional value is needed in the DocumentSpecName-attribute to fully define the schema. So the above syntax value is not enough, it will direct the pipeline to the desired schema in the assembly, but it doesn’t say which root it should validate against.

The correct syntax in this case is : “<schema type>+<root name> ,<schema assembly full name>”
By adding the root name after the ‘+’ -sign the issue for schemas with multiple root nodes is solved.