WCF WinSCP-based SFTP Adapter
Since Microsoft now supplies a SFTP Adapter with Biztalk Server 2016, we thought we might as well try it out instead of using the Blogical one (which we have had several problems with).
It is relatively straightforward to use it in static sendports and receivelocations – the only thing we miss, is a possibility to use temporary filenames during transmission, which it does not support – only temporary folders.
However, it does not seem to be documented how to use the adapter in a dynamic sendport (at least, we have been unable to find it)
As documented, the SFTP Adapter uses the WinSCP program to do its actual work and specifically, it requires the WinSCPnet.dll to do its work.
Microsoft have implemented the WCF adapter in this DLL which wraps the calls to WinSCP.
C:\Program Files (x86)\Microsoft BizTalk Server 2016\Microsoft.BizTalk.Adapter.Sftp.dll – Assembly version 3.0.1.0
The Adapter loads the WinSCPnet DLL in the class SftpHelper.
The dynamic properties can be found in the class SftpOutputChannel Method AddPropertiesFromMessageContext.
Context Property | Description |
---|---|
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#ClientAuthenticationMode | this.sendPropertyBag.ClientAuthenticationMode = (ClientAuthenticationMode) Enum.Parse(typeof (ClientAuthenticationMode), property.Value.ToString());
enum Password, PublicKeyAuthentication, MultiFactorAuthentication |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#UserName | Either specify UserName and Password, or specify a keyfile in PrivateKeyFile |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#Password | Password |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#PrivateKeyFile | Full path to Private Key |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#PrivateKeyPassword | Password to the private key, if it is password protected |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#AccessAnyServerHostKey | If False, host fingerprint must be specified. If True, all hosts will be accepted |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#SSHServerHostKeyFingerPrint | Specify the fingerprint of SSH servers HostKey, if “AccessAnyServerHostKey” is False |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#AppendIfExists | If False, transfer will fail if a file with the filename already exists. If True, the contents will be appended to the existing file
We have not been able to make the “AppendIfExists” work. If this property is true, the adapter issues a get command for the filename, and if the file does not exist yet (first transfer), then the transmission fails. |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#TargetFileName | The name of the file created on the SFTP server. You can use the macros specified below |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#TemporaryFolder | this.sendPropertyBag.TemporaryFolder = property.Value.ToString(); |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#ProxyAddress | Address of a proxy-server, if you need to use one, or blank. |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#ProxyUserName | Username and password for the proxy-server, or blank if they are not needed |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#ProxyPassword | |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#ProxyPort | Port for the proxy-server |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#ProxyType | this.sendPropertyBag.ProxyType = (Microsoft.BizTalk.Adapter.Sftp.ProxyType) Enum.Parse(typeof (Microsoft.BizTalk.Adapter.Sftp.ProxyType), property.Value.ToString());
enum None, SOCKS4, SOCKS5, HTTP |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#EncryptionCipher | this.sendPropertyBag.EncryptionCipher = (EncryptionCipher) Enum.Parse(typeof (EncryptionCipher), property.Value.ToString());
enum Auto, AES, Arcfour, BlowFish, TripleDES, DES |
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#Log | this.sendPropertyBag.Log = property.Value.ToString(); |
http://schemas.microsoft.com/BizTalk/2003/system-properties#OutboundTransportLocation | Contains the full EndPointAddress of the server – on the form sftp://servername:port
this.ParseSftpUrl(property.Value.ToString()); |
OutboundTransportLocation needs to be ‘sftp’ (case insensitive compare)
Supported macros
Macro | Value |
---|---|
Use fixed context-property | |
%MessageID% | http://schemas.microsoft.com/BizTalk/2003/system-properties#BizTalkMessageID |
%SourceFileName% | http://schemas.microsoft.com/BizTalk/2003/file-properties#ReceivedFileName |
Use the macro as the name of a context-property Use the contextproperty with the namespace namespace http://schemas.microsoft.com/BizTalk/2003/system-properties# with the macroname (nix the percent-signs) appended |
|
%DestinationParty% | |
%DestinationPartyQualifier% | |
%SourceParty% | |
%SourcePartyQualifier | |
These macros formats either DateTime.Now or DateTime.UtcNow in the specified format | |
%datetime% | yyyy-MM-ddThhmmss |
%datetime_bts2000% | yyyyMMddhhmmssf |
%datetime.tz% | yyyy-MM-ddThhmmsszzz |
%time% | hhmmss |
%time.tz% | hhmmsszzz |