Which SAP NCo version to pick for Azure Logic Apps SAP Connector

There is some confusion for our users as to which version of SAP NCo to use as there are many flavors to download from the SAP marketplace. This post intends to clarify which version to download and why.

The reason we Microsoft are not simply shipping the SAP NCo assemblies as part of the On Premises Data Gateway is the non-redistribution licensing by SAP for said assemblies. (If you do work for SAP and could help reach an agreement for our common customers so we ship your assemblies as part of our product, please do reach out!).

We need users to install the 64 bit version, and only the 64 bit version, because the data gateway host service runs exclusively in 64 bit (it is compiled so). There has been incorrect instructions given on MSDN forum  to install both 32 bit and 64 bit versions, which is wrong. 64 bit processes such as the data gateway host service cannot load 32 bit assemblies and there will be an error if attempted to (bad image). If you see this error:

 Could not load file or assembly 'sapnco, Version=3.0.*.*, Culture=neutral, PublicKeyToken=50436dca5c7f7d23' or one of its dependencies. An attempt was made to load a program with an incorrect format. 

It means that the 32 bit version of the sapnco assembly has been put first on the loading path for the data gateway host service. Remove the 32 bit version and install the 64 bit version. As a side note, BizTalk Server is a 32 bit process, it is not compiled for 64 bit and on the opposite of the On Premises Data Gateway requires the 32 bit version of the SAP NCo.

We need users to install the latest version of SAP NCo as well (3.0.20.0 as of now). Earlier versions (including but not limited to 3.0.13.0 and 3.0.15.0) have a race condition leading to deadlock when two IDoc messages are sent at the same time. The SAP NCo will not recover from the deadlock for the matching SAP destination and all subsequent message send to that destination will block and timeout. You can read details of the fix on SAP's release notes here (SAP marketplace account is required to open this page). Users will further see a spike in the open network connections for the data gateway host service as all these blocking calls are each consuming a connection until they timeout. Especially under load, you will quickly run up to the maximum concurrent calls limits (50 open WCF channel per SAP destination, after which the data gateway host service uses up to 256 network connections picking messages from the Service Bus WCF relay). If you see this error:

     "message": "BadGateway",
    "innerError": {
      "status": 504,
      "message": "Request to SAP server timed out.",

Make sure you have the latest version of SAP NCo installed.

We need users to install the .NET 4.0 version of SAP NCo as the data gateway host service and Microsoft SAP Adapter are themselves build with .NET 4.5. The SAP NCo version for .NET 4.0 is compatible with processes using the .NET runtime 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, or 4.7.1, and the version for .NET 2.0 is compatible with processes using using the .NET runtimes 2.0, 3.0, or 3.5 (which is not On Premises Data Gateway's case).

Finally, there are two ways you may install the SAP NCo assemblies. You may either copy them to the On Premises Data Gateway installation folder (by default C:\Program Files\On-premises data gateway) or you may install them in the GAC. Either approach is supported. I personally recommend copying the SAP NCo assemblies to the On Premises Data Gateway installation folder to reduce ambiguity as to what will be loaded and avoid potential conflict of versions with other software installed on the same machine. As a side note, BizTalk Server has typically made use of the GAC, even GAC'ing assemblies itself during installation for a number of capabilities such as flat file processing, XML schema and transform map authoring. This has lead to difficulties having both BizTalk Server and other integration software on the same machine.